Showing posts with label note-to-self. Show all posts
Showing posts with label note-to-self. Show all posts

Saturday, January 20, 2018

Note to self: How to re-enable terminal escape sequences in new WindowsConsole


Windows 10 "fall creators update" 2017, more precisely known as Windows 10 version 1709, brings with it a new version of the windows console.
This is the terminal that is used to display cmd.exe and PowerShell commandline environments.

Now the new version is nice, amongst other things it has is variable transparency, but it turns off processing terminal escape sequences from Python (and probably a load of other things) by default.

This is how to turn on the processing of terminal escape sequences in Win10 console V2.

Using RegEdit add "VirtualTerminalLevel" as a DWORD to ‘HKCU\Console’ set to value 0x1


restart the console and bob is your uncle.


Thursday, November 23, 2017

Note to Self: How to open the react-native debug menu without the rage-shake


I've been playing around with react-native for a week or so, and I'm liking it.
If you don't know what it is, its basically a toolkit for building mobile apps with, one that makes it easy to achieve good looking apps that integrate with your phone without you having to learn low-level details about how phones work (yay for that!).
One of the great things is that, with Android at least, you can use your own favourite editing tools and the Android SDK and react-native will build your app, install it on your phone, start it running, and attach a debugger to the app and the developer tools in your web browser.
All from one simple command:

react-native run-android

It even has a hot-patch and automatic re-load ability so that the running app updates as you edit your source files.
But one thing has been bugging me like mad, though, there is a "secret" menu of developer options installed in the app, including an option to force a reload, but it requires a "rage-shake" to wake it on the phone.
Or should I say it did.. because if you have your phone tethered with a USB to the Android Debug Bridge (adb) you can issue a keypress signal over adb and bind that to a menu or a keyboard shortcut in your computer. Yes, indeed, open a menu on the phone screen with a press of a key in your editor! All you have to do is to bind this command to a shortcut or key binding, and Bob's your uncle.:

adb shell input keyevent 82 


Sunday, July 30, 2017

Note to self: How to reset windows permissions


We have just copied a big chunk of files off a broken home NAS by mounting the hdd in a windows PC. Luckily this one has a windows format partition on it, the other one doesn't so I'll need to make a bootable Linux USB dongle, probably via https://www.pendrivelinux.com/ and boot from that.

However back to windows, and I can't read any of the files on Win10 because the permissions don't map onto the users and groups in Win10, and UAC doesn't help because it won't allow me to "be" an administrator.

But I found the answer! :-D
Run powershell "as administrator" cd to the broken directory and use this command to recursively reset the permissions to the system default set for a whole tree.:

icacls .\ /reset /T /C /L

If that doesn't work you can take ownership of the tree using this command and then try the icacls (eye cackles?) command again

takeown.exe /F .\ /R


Thursday, April 14, 2016

Note to self: How to mount virtualbox shared folders RW, and enable symlinks


So these are two commands to mount shared folder in a linux host on a linux guest so that the guest has full permission in the shared folders.

This first command should be executed on the guest VM

sudo mount -t vboxsf SHARE_NAME /MOUNT_POINT/ -o rw,users,umask=0000

This next command enables symlink creation and should be executed on the host.

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1 


Thursday, December 10, 2015

Note To Self: Display Raspberry Pi CPU Temperature


I have recently been messing around with a raspberry pi at work (a Pi2 model B) for driving display screens for our In-Venue product of which I am the product owner. And very exciting it is too, because the real world is the new frontier (this pdf is also a good primer). If you see what I mean, but more on that another time.

So.. I had to overclock the Pi to improve browser performance to even get near to acceptable speed and smoothness of animations. Pro Tip, the Pi is not a graphics device! Having done this and got acceptable results for a clunky prototype to demo with, and load averages that stayed on the sane side of normal I thought I'd better see if I was frying the CPU. And because I will inevitably forget this useful command I'm saving it here for posterity. Here's how I got the temperature reading..

/opt/vc/bin/vcgencmd measure_temp
Enjoy!


Friday, February 27, 2015

Put code in your google docs


I'm writing a technical document using google docs, and I want to put code snippets into it.
I thought this would be hard, before I discovered http://hilite.me/

This awesome, and awesomely simple, web app converts snippets of code into coloured HTML.
It can format a comprehensive range of languages and apply an equally impressive variety of styles.

Here's a snip of javascript, I just copied and pasted it straight in here, so it doesn't handle the overflow well, but you have to admit that its pretty cool for something that has a quick copy/paste/click/copy/paste workflow:


for (var i = 0; i < dataObj.eventData.children.length; i++) {
  if (dataObj.isProduction){
   dataObj.eventData.children[2].outcome.coupling = "1";
  }
  if (dataObj.eventData.children[i].outcome.coupling.length > 0) { 
    outcomeData = dataObj.eventData.children[i].outcome;
    priceBoost[counter] = Object.create(priceBoostObject);
    priceBoost[counter].createPriceBoostHTML(outcomeData);
    priceBoost[counter].applyPriceBoost(outcomeData);
    priceBoost[counter].applyExtraCss(outcomeData);
    priceBoost[counter].initialiseAnimatedImages('animated-' + outcomeData.id, 'images/test.png', 'test.html');
    priceBoost[counter].checkTextWidth(outcomeData.id);
    counter++;
  }
}


Thursday, May 30, 2013

note to self, how to fix "requires installation of untrusted packages" in Ubuntu


I tried to install a couple of updates on my work laptop, running Ubuntu 12.04, a minute or two ago when prompted by the update manager, and I got the "requires installation of untrusted packages" error. I've since dicovered that there are two ways round this, one is to allow untrusted packages by doing the update as root or via sudo, and saying "y" when asked

Install these packages without verification [y/N]?
But I don't like that, you don't know who might be spoofing you with what fake packages. The better way is to rebuild the apt cache. I found the instructions here, I'm claiming no credit for solving the problem, just reproducing them below so that I can be sure to find them again next time I need them. Hopefully some of you who read this in the future will also benefit.

sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get clean 
sudo apt-get update

Enjoy!


Wednesday, October 19, 2011

Note to self, how to get a list of recipients from the maillog


I spent a while figuring out how to get a list of email recipient addresses from the maillog, without duplicates, for a specific day on RHEL. In the end I distilled it into to one line.

I'm sure I will have to do it again, so I'm making a note of it here, meantime if you need to extract recipient addresses from maillog you're welcome to try it. just paste it onto the command line and hit the go button, its surpisingly quick.

cat /var/log/maillog | grep "Oct 19" |\
grep to= |cut -f5 -d":" | cut -f2 -d"=" | cut -f1 -d"," | \
sed 's/<//' | sed 's/>//' | \
sort | uniq > addresses.txt


Thursday, January 27, 2011

note to self, MySQL query profiler


Update The original article mentioned in this post is no longer available, but if you are still interested in query profiling in MySQL, check out this http://dev.mysql.com/doc/refman/5.0/en/show-profiles.html
I will write up an quick start guide to profiling myself here, one day.
 
-- original post
this article is a great way to get started using the mysql query profiler.

If you've never used it before take some time to check it out, it will change the way you think about the database forever.


Wednesday, January 19, 2011

Note to self, how to get the top tens from MySQL slow query log


Use these two commands to get the top ten and top ten repeaters from MySQL's slow query log.

mysqldumpslow -t 10 ./slow-log > /home/danny/top_ten_slow_query.txt

mysqldumpslow -a -s c -t 10 ./slow-log > /home/danny/top_ten_repeat_slow_query.txt


Thursday, January 13, 2011

Note to self, how to delete files older than


Yes, yet another one that I always have to look up, I think it must be my age!

find /path/to/files* -mtime +5 -exec rm {} \;


Wednesday, October 20, 2010

Note to self, how to get row numbers in a MySQL SELECT


I've often wondered, idly, how to get MySQL to output a row number column, which would rank sorted and grouped results.
Well thanks to this excellent post I've found out how:

SELECT *, @rownum:=@rownum+1 as rank FROM ( 
-- Your Query Goes in Here
        SELECT t.*
        FROM table t
        WHERE something
        group by 2,3,4
        order by 1 desc limit 20
    ) day_rank, (SELECT @rownum:=0) r;


Thursday, September 23, 2010

Note to self, how to install apc


Want to install apc on CENTOS or RHEL?
REad this: http://www.agileapproach.com/blog-entry/howto-install-pecl-apc-cache-centos-without-xampp


Tuesday, September 21, 2010

Note to self, want stats on nfs usage, try this


I thought I'd put this in as well, since I had to google for it, using -n will make iostat provide you with stats for nfs shares too.

iostat -nh 5
You can also use nfsstat

nfsstat -cvn -o nfs


Wednesday, September 01, 2010

note to self, how to change the definer of a mysql stored procedure


This is a useful one if, like us, you find that the account used to create the procedure doesn't have the privileges required to execute it, or perhaps you've revoked the original definers grant. (DoH!)

ALTER PROCEDURE procedure_name SQL SECURITY DEFINER;javascript:void(0)


Tuesday, August 31, 2010

note to self, how to use your favourite editor for the crontab without changing it permanently


I like to use nano to edit the crontab, but I don't want to change the default editor.
(Some people are very un-funny about that kind of thing!)

This is the one-liner to use nano, and I seldom remember it.

env EDITOR=nano crontab -e


Wednesday, August 25, 2010

note to self, how to make a mysql instance read-only


Another piece of DBA hoodoo that I seldom need!

SELECT @@global.read_only;
SET GLOBAL read_only=1;
SELECT @@global.read_only;


note to self, how to skip a mysql replication error


Another one that I have to google every time.
Not being a DBA I don't do this very often, but now and again I find myself in the Hot Seat.

SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
SHOW SLAVE STATUS;


Wednesday, August 18, 2010

note to self, how to convert pfx to pem without passphrase


I do this so infrequently that I always have to google it.
Now I can search my own blog!
openssl pkcs12 -in mycert.pfx -out certificate.cer -nodes


I know nothing, I'm not a fortune teller, and you'd be insane to think that I am. This disclaimer was cribbed from an email footer I once received. It is so ridiculous I had to have it for myself.

Statements in this blog that are not purely historical are forward-looking statements including, without limitation, statements regarding my expectations, objectives, anticipations, plans, hopes, beliefs, intentions or strategies regarding the future. Factors that could cause actual results to differ materially from the forward looking statements include risks and uncertainties such as any unforeseen event or any unforeseen system failures, and other risks. It is important to note that actual outcomes could differ materially from those in such forward-looking statements.

Danny Angus Copyright © 2006-2013 (OMG that's seven years of this nonsense)