Skip to content

Instantly share code, notes, and snippets.

@vjyanand
vjyanand / gist:1960835
Created March 2, 2012 19:48
List Installed Perl Modules
perl -MExtUtils::Installed -e 'my $Inst = ExtUtils::Installed->new();my @Modules = $Inst->modules(); for my $module (@Modules) { print "$module " . $Inst->version($module) . "\n"; } '
#!/bin/bash
##########################
## Check if run as root ##
##########################
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@vjyanand
vjyanand / gist:984b9bf2041a604322fd
Created September 30, 2014 14:36
version check
NSOperatingSystemVersion ios8_1_0 = (NSOperatingSystemVersion){8, 1, 0};
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:ios8_1_0]) {
// Read and write workout information to health kit.
} else {
// Write workout information to health kit
}
openssl pkcs12 -nocerts -out aps_private-key.pem -in aps_private-key.p12
openssl x509 -in aps_development.cer -inform der -out aps_development.pem
openssl pkcs12 -export -in aps_development.pem -out aps_dev_credentials.p12 -inkey aps_private-key.pem
@vjyanand
vjyanand / install.sh
Created December 10, 2015 12:55
Installing tesseract on SmartOS
git clone https://github.com/tesseract-ocr/tesseract.git
cd tesseract/
pkgin in autoconf automake libtool
wget "http://www.leptonica.com/source/leptonica-1.72.tar.gz"
cd leptonica-1.72
CFLAGS="-D__SOLARIS__"
./configure --prefix=/opt/local
make && make install
cd ..
export LIBLEPT_HEADERSDIR=/tmp/tesseract/leptonica-1.72/src
@vjyanand
vjyanand / gist:9ff5628e92dde25522e2
Last active January 30, 2016 06:20
smartos ipv6
svcadm enable ndp
ifconfig bge0 inet6 plumb
ifconfig bge0 inet6 addif 2607:f128:0421:0081:0732:0003:1208:3300/64 up
route add -inet6 2607:f128:0421:0081::1 2607:f128:0421:0081:0732:0003:1208:3300 -interface
route add -inet6 default 2607:f128:0421:0081::1
dladm create-bridge six
dladm create-etherstub stub2
dladm set-linkprop -p mtu=1500 stub2
@vjyanand
vjyanand / gist:38b7286dfdc0d0670285
Created February 1, 2016 10:27
fade in fade out
let avUrlAsset = AVAsset(URL: _url)
let duration = avUrlAsset.duration
let durationInSeconds = CMTimeGetSeconds(duration)
let item = AVPlayerItem(asset: avUrlAsset, automaticallyLoadedAssetKeys:["duration"])
let params = AVMutableAudioMixInputParameters(track: avUrlAsset.tracks.first! as AVAssetTrack)
let firstSecond = CMTimeRangeMake(CMTimeMakeWithSeconds(0, 1), CMTimeMakeWithSeconds(15, 1))
let lastSecond = CMTimeRangeMake(CMTimeMakeWithSeconds(durationInSeconds - 1, 1), CMTimeMakeWithSeconds(1, 1))
params.setVolumeRampFromStartVolume(0, toEndVolume: 1, timeRange: firstSecond)
params.setVolumeRampFromStartVolume(1, toEndVolume: 0, timeRange: lastSecond)
let mix = AVMutableAudioMix()
@vjyanand
vjyanand / gist:fdf02baa573436741c17
Last active February 3, 2016 03:15
selenium webdriver chrome headless
export DISPLAY=:10
Xvfb :10 -screen 0 5120x2880x24 -ac &
google-chrome --start-maximized --remote-debugging-port=9222 &
cd /usr/local/bin
nohup java -jar ./selenium-server-standalone-2.50.1.jar &
ps -O etimes -eo pid,etime,comm,user,tty | grep chrome | grep -v grep | awk {'if ($2 > 100) print $1'} | xargs kill
sudo yum install cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango gtk3-devel alsa-lib libXScrnSaver git-core memcached nodejs cargo openssl-devel