Skip to content

Instantly share code, notes, and snippets.

@intarstudents
intarstudents / keysharky_applescript.md
Created March 26, 2013 20:27
keySharky AppleScript app for toggling bash

Create AppleScript:

do shell script "/usr/local/bin/wget http://localhost:8800/play --spider"

Save as Application. In Applications folder find Info.plist and add these lines, so Application will not show in Dock:

NSUIElement
/var/log/path/to/nginx/*_log {
daily
missingok
rotate 20
compress
delaycompress
notifempty
sharedscripts
postrotate
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
@intarstudents
intarstudents / zero.sh
Created February 6, 2013 19:40
Delete zero sized songs from iOS Music player
echo "DELETE FROM item WHERE item_pid IN (SELECT item_pid FROM item_extra WHERE file_size = 0);
DELETE FROM item_search WHERE item_pid IN (SELECT item_pid FROM item_extra WHERE file_size = 0);
DELETE FROM item_stats WHERE item_pid IN (SELECT item_pid FROM item_extra WHERE file_size = 0);
DELETE FROM item_extra WHERE file_size = 0;" | sqlite3 /var/mobile/Media/iTunes_Control/iTunes/MediaLibrary.sqlitedb
@intarstudents
intarstudents / php_background.php
Created January 27, 2013 09:14
PHP launch background process (linux)
<?php
$pid = shell_exec("nohup /command/running/in/background > /dev/null 2> /dev/null & echo $!");
@intarstudents
intarstudents / wireshark-non-root.sh
Created January 23, 2013 09:33
Wireshark on Ubuntu as non-root
sudo dpkg-reconfigure wireshark-common
# Select yes
sudo chmod +x /usr/bin/dumpcap
@intarstudents
intarstudents / pgadmin-ppa.sh
Created January 21, 2013 10:37
Ubuntu pgAdmin PPA
apt-add-repository ppa:pitti/postgresql
apt-get update && apt-get upgrade
<?php
$zmqc = new ZMQContext();
$sub = $zmqc->getSocket(ZMQ::SOCKET_SUB);
$sub->connect("tcp://IP:PORT");
$sub->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, "");
var_dump($sub->recvMulti());
@intarstudents
intarstudents / flash_version_in_swf.php
Created December 20, 2012 09:22
Get version in which SWF file is compiled
<?php
/**
* Get version in which SWF file is compiled
* @param string $file_path Path to SWF file
* @return int Version number (or -1 on error)
*/
function swf_version($file_path){
$ret = -1;
$fh = @fopen($file_path, "r");
@intarstudents
intarstudents / fix_synapse_apps.sh
Created November 13, 2012 20:58
Linux Mint 13 & 14 (MATE) - Fix missing application shortcuts in Synapse
#!/bin/sh
for file in $(grep -il "^OnlyShowIn=MATE;$" /usr/share/applications/*.desktop); do
echo "patching $file"
sed -e "s/OnlyShowIn=MATE;/#OnlyShowIn=MATE;/ig" $file > /tmp/tempfile.tmp
mv -f /tmp/tempfile.tmp $file
done
@intarstudents
intarstudents / virtualbox_respository_ubuntu.md
Created October 26, 2012 19:06
How to add VirtualBox respository (Ubuntu)

Open source.list in your favorite text editor:

$ sudo nano /etc/apt/sources.list

Append this line and save changes:

deb http://download.virtualbox.org/virtualbox/debian precise contrib