Skip to content

Instantly share code, notes, and snippets.

View raedatoui's full-sized avatar

Raed Atoui raedatoui

View GitHub Profile
@raedatoui
raedatoui / gist:2492728
Created April 25, 2012 19:39
kill process by name in Terminal
alias kp=kill_process
kill_process(){
ps -ef | grep $@ | grep -v grep | awk '{print $2}' | xargs kill -9
}
e.g: you may have ran 'rails s &', 'gitk &', 'middleman &'
you kill with kp rails
useful to logout of all current ssh connections
@raedatoui
raedatoui / gist:2597831
Created May 4, 2012 21:26
Swagger nested resources
//resources.json
{
"apiVersion": "0.1",
"apis": [
{
"description": "Operations about projects",
"path": "/project.{format}"
},
{
"description": "Operations about tickets",
@raedatoui
raedatoui / gist:3230784
Created August 1, 2012 21:10
json responses
def render_json_response(type, hash)
unless [ :ok, :error ].include?(type)
raise "Invalid json response type: #{type}"
end
default_json_structure = {
:status => type,
:data => nil,
:error => nil,
@raedatoui
raedatoui / nginx_config
Created December 7, 2012 19:39
Nginx sample config
upstream unicorn_production {
server unix:/usr/local/nature-valley/current/tmp/sockets/unicorn.sock;
}
server {
listen 80;
server_name "Name of the server";
access_log /var/log/nginx/nv.log;
error_log /var/log/nginx/nv.error.log;
root "public directory of Rails App;
@raedatoui
raedatoui / gist:5690717
Last active December 17, 2015 23:39
Spine file upload
@form.ajaxForm
dataType: 'json'
beforeSend: =>
# ui treatement
uploadProgress: (event, position, total, percentComplete) =>
# progress ui
complete: (xhr) =>
# fetch model based on id
@raedatoui
raedatoui / gist:7331261
Created November 6, 2013 05:13
uninstall node.js
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
@raedatoui
raedatoui / activeadmin_sortable.js.coffee
Last active August 29, 2015 14:05 — forked from robertjwhitney/activeadmin_sortable.js.coffee
Same concept, and make the collection_action return HTML markup to reflect the newly sorted items. Requires Nokogiri for parsing the html
# http://stackoverflow.com/a/8936202
#
# ActiveAdmin already includes the necessary jquery in active_admin/base,
# so just add this to javascripts/active_admin.js after //= require active_admin/base
#
#
# Serialize and Sort
#
# model_name - you guessed it, the name of the model we are calling sort on.
# This is the actual variable name, no need to change it.
@raedatoui
raedatoui / gist:010ec9ba41aaaec0789a
Last active August 29, 2015 14:08
Save colorized git graph from terminal to html file
inigo:tmp> script
Script started, file is typescript
inigo:tmp> git --no-pager log --pretty=format:"" --graph
#
# lots of colour output
#
inigo:tmp> exit
exit
Script done, file is typescript
# http://www.pixelbeat.org/scripts/ansi2html.sh
@raedatoui
raedatoui / ripple.frag
Created August 14, 2016 23:55 — forked from alco/ripple.frag
Ripple effect for GLSL
// simple fragment shader
// 'time' contains seconds since the program was linked.
uniform float time;
uniform sampler2D tex;
uniform sampler2D tex2;
float radius = .5;
@raedatoui
raedatoui / scraper.go
Last active January 10, 2017 17:56
Scrape and test links from files using Golang
package main
import (
"fmt"
"golang.org/x/net/html"
"io"
"log"
"net/http"
"os"
"sort"