Skip to content

Instantly share code, notes, and snippets.

View raedatoui's full-sized avatar

Raed Atoui raedatoui

View GitHub Profile
@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 / gist:2044730
Created March 15, 2012 15:13
Expression Engine JSON output
[{exp:channel:categories channel="sections" style="linear"}
{"name":"{category_name}",
"thumb":"{category_image}",
"id":"{category_id}",
"image":"{image}",
"description":"{category_description}",
"pages":{exp:json:entries channel="sections" orderby="display_order" sort="asc" category="{category_id}"}},
{/exp:channel:categories}
{"id":"-1"}]
@raedatoui
raedatoui / gist:2055680
Created March 17, 2012 06:10
Converting GPS from mmmm ss to dddd for Google Maps API
## SAMPLE data 3603.7517 N 11212.6268 W
lat_sign = LAT_FROM_DATA > 0 ? 1:-1
lat = LAT_FROM_DATA
lat = lat[0,lat.length-1] #strip N
arr = lat.split('.')
if arr[0].length == 4
deg= arr[0][0,2].to_f
min = arr[0][2,4].to_f
seconds = arr[1].to_f
lat = (deg + min/60 + seconds/600000).to_f
@raedatoui
raedatoui / gist:2055720
Created March 17, 2012 06:16
avi jpg sequence using ffmpeg
ffmpeg -i input.avi -y -an -sameq -f image2 out/still-%03d.jpg
@raedatoui
raedatoui / gist:2055723
Created March 17, 2012 06:18
process all images in a folder using imagemagick
find . -iname "*.jpg" | perl -e 'for(<>) { chomp $_;@a=split(/\//,$_);$str = "convert -resize 15% -quality 60 $_ _".$a[-1];print $str."\n";`$str`}'
@raedatoui
raedatoui / gist:2055870
Created March 17, 2012 06:51
active admin tricks
index do
column :image, :sortable => :image do |model|
if model.image.to_s.nil?
raw('&#8212;')
else
raw('&#x2713')
end
end
end
@raedatoui
raedatoui / gist:2161387
Created March 22, 2012 18:33
mysql select concat links
SELECT CONCAT('http://naturevalleytrailview.com/',parks.slug,'/',trails.slug,'#panorama-',interest_points.slug)
FROM `interest_points`
LEFT JOIN trails ON trails.id = interest_points.trail_id
LEFT JOIN parks ON parks.id = trails.park_id
WHERE `poi_type_id` = 1 ORDER BY parks.id
@raedatoui
raedatoui / gist:2271033
Created April 1, 2012 03:49
wp mu aggregate
function wpmu_latest_post_links($blog_path, $how_many = 10, $how_long_days = 30, $how_many_words = 50, $more_text = "[...]", $remove_html = true, $sort_by = 'post_date') {
global $wpdb;
//first, gat all blog id
$query = "SELECT blog_id FROM $wpdb->blogs WHERE blog_id !='1' AND path='" . $blog_path . "'";
$blogs = $wpdb->get_col($query);
if ($blogs) {
//we use blog id to loop post query
foreach ($blogs as $blog) {
@raedatoui
raedatoui / gist:2325600
Created April 7, 2012 05:43
nginx worpdress config
server {
listen 80;
server_name raedatoui.com www.raedatoui.com;
access_log /srv/www/raedatoui.com/logs/access.log;
error_log /srv/www/raedatoui.com/logs/error.log;
root /srv/www/raedatoui.com/public;
location / {
#index index.html index.htm index.php;