Skip to content

Instantly share code, notes, and snippets.

@nicnocquee
nicnocquee / get_twitter_video_to_gif.sh
Created February 24, 2016 11:16
Get twitter video from url then convert to gif. Usage: ./get_twitter_video_to_gif <url> <filename>
#/bin/sh
curl -s -L -G "$1" > tmp
url=`grep -o 'https:\/\/pbs\.twimg\.com\/tweet_video\/.*\.mp4' tmp`
echo $url
curl -s -G $url > $2.mp4
palette="palette.png"
filters="fps=10,scale=320:-1:flags=lanczos"
@nicnocquee
nicnocquee / command_line_arguments.sh
Created February 15, 2016 15:09
To parse command line arguments
# Changes zsh globbing patterns
unsetopt NO_MATCH >/dev/null 2>&1 || :
# Dispatches calls of commands and arguments
dispatch ()
{
namespace="$1" # Namespace to be dispatched
arg="${2:-}" # First argument
short="${arg#*-}" # First argument without trailing -
long="${short#*-}" # First argument without trailing --
@nicnocquee
nicnocquee / new_script.sh
Created February 12, 2016 10:17
Script to create shell script
#!/bin/bash
# ---------------------------------------------------------------------------
# new_script - Bash shell script template generator
# Copyright 2012, William Shotts <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@nicnocquee
nicnocquee / buildstaticlib.sh
Created January 20, 2016 20:22
Script to create fat static library for iOS
#!/bin/bash
# This script is based on https://gist.github.com/rehos/7856163
if [ -z "$1" ]; then
echo
echo "usage: $0 <project.xcodeproj> [<scheme>]"
echo
exit
fi
@nicnocquee
nicnocquee / buildstaticlib.sh
Last active January 20, 2016 18:48
Script to create fat static library for iOS using xctool
#!/bin/bash
# This script is based on https://gist.github.com/rehos/7856163
if [ -z "$1" ]; then
echo
echo "usage: $0 <project.xcodeproj> [<scheme>]"
echo
exit
fi
@nicnocquee
nicnocquee / lyrics_of_songs_in_folder.sh
Last active January 18, 2016 15:59
Script to find lyric of songs in a given folder. Requires mediainfo.
#!/bin/sh
# Require mediainfo: brew install mediainfo
function readSong () {
if [ "$1" != "." ] ; then
TITLE=`mediainfo "$1" | grep "^\Track name\ *:" | sed 's/.*Track name\ *:\ //g'`
ARTIST=`mediainfo "$1" | grep "^\Performer\ *:" | sed 's/.*Performer\ *:\ //g'`
FILENAME=`mediainfo "$1" | grep "^\Complete name\ *:" | sed 's/.*Complete name\ *:\ //g' | sed 's/\.mp3$/\.txt/g' | sed 's/\.m4a$/\.txt/g'`
echo "Fetching lyric "$ARTIST" "$TITLE" ... "
LYRIC=`curl --data-urlencode "artist=$ARTIST" --data-urlencode "title=$TITLE" -G -s "http://makeitpersonal.co/lyrics"`
@nicnocquee
nicnocquee / organize_photos.sh
Created January 13, 2016 10:32
Script to organize photos by grouping them into folders of year and month of date taken. Requires imagemagick.
#!/bin/sh
function readImage () {
if [ "$1" != "." ] ; then
DIRTOMAKE=`identify -verbose "$1" | grep exif:DateTime: | sed 's/exif\:DateTime\: //g' | sed 's/\:[0-9][0-9] [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9]//g' | sed 's|:|/|g'`
trimmed=`echo "$DIRTOMAKE" | xargs`
if [ -z "$trimmed" ] ; then
trimmed="Unknown"
fi
@nicnocquee
nicnocquee / cocos2d-x_let_song_play.m
Last active September 29, 2015 01:43
Cocos2d-x sound effect while letting user's song playing in iOS
// AppController.mm
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[CDAudioManager sharedManager] setMode:kAMM_FxPlusMusicIfNoOtherAudio];
return YES;
}
// in other file
@nicnocquee
nicnocquee / update_xcode_plugins_uuid.sh
Created April 9, 2015 01:57
Fix plugins not working after Xcode update
XCODEUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
for f in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*; do defaults write "$f/Contents/Info" DVTPlugInCompatibilityUUIDs -array-add $XCODEUUID; done
@nicnocquee
nicnocquee / setup.sh
Last active August 29, 2015 14:13 — forked from jmathai/setup.sh
#!/bin/bash
SCREEN=$(which screen)
if [ "$SCREEN" = "" ]
then
echo "Install screen then rerun"
exit 0
fi
if [ "$STY" = "" ]