Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
References:
http://blog.carbonfive.com/2012/02/27/supporting-cross-domain-ajax-in-rails-using-jsonp-and-cors/
https://github.com/cyu/rack-cors
http://nelm.io/blog/2011/11/cors-with-sencha-touch/
http://jessehowarth.com/2011/04/27/ajax-login-with-devise
=============================================================================================================
GEMFILE
=============================================================================================================
gem 'rack-cors', :require => 'rack/cors'
mat4 rotationMatrix(vec3 axis, float angle)
{
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
@nongio-zz
nongio-zz / baseclass.scss
Created June 12, 2014 13:07
scss to reproduce sassc bug
.baseclass {
position: relative;
width: 116px;
height: 142px;
margin: 6px 0px 0px 6px;
> img {
width: 114px;
height: 114px;
}
&__label {
@nongio-zz
nongio-zz / phpserve.js
Created July 28, 2014 13:43
serve simple php file using nodejs
var cgi = require('cgi'),
http = require('http'),
path = require('path');
var script = path.resolve(__dirname, 'index.php');
http.createServer( cgi(script) ).listen(3000);
@nongio-zz
nongio-zz / node-term-tools.md
Last active November 13, 2017 17:23
nodejs terminal UI tools

nodejs terminal UI tools

Inquirer A collection of common interactive command line user interfaces. Used by yeoman

terminal-menu used in rvagg/workshopper learnyounode...

cli-color used in rvagg/workshopper learnyounode...

blessed A curses-like library for node.js.

@nongio-zz
nongio-zz / webm.md
Last active August 29, 2015 14:08 — forked from ndarville/webm.md

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@nongio-zz
nongio-zz / unite_vimrc.vim
Last active August 29, 2015 14:09
unite vim config
" Unite
"unite ctrl-p functionality
call unite#filters#matcher_default#use(['matcher_fuzzy'])
nnoremap <space>b :Unite -quick-match buffer<cr>
nnoremap <space>p :<C-u>Unite file_rec/async<cr>
"unite grep
nnoremap <space>f :<C-u>Unite grep:.<cr>
nnoremap <space>F :<C-u>Unite grep<CR>
"unite history yank
#!/bin/sh
current_branch="$(git rev-parse --abbrev-ref HEAD)" || ""
if [ "$current_branch" != "" ];then
echo "your are not in a git repository!!"
else
mr_url="$(bundle exec git gitlab merge $current_branch master | sed -n 2p)"
echo $mr_url | pbcopy
echo $mr_url
fi
@nongio-zz
nongio-zz / spotify_status.sh
Created July 22, 2015 10:38
check current status of spotify
#!/usr/bin/env bash
state=`osascript -e 'tell application "Spotify" to player state as string'`;
if [ $state = "playing" ]; then
current=`osascript -e 'tell application "Spotify"' -e 'set currentArtist to artist of current track as string' -e 'set currentTrack to name of current track as string' -e 'return currentArtist & " - " & currentTrack' -e 'end tell'`;
echo "$current 🔊 ";
else
echo "🙊"
fi