This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//resources.json | |
{ | |
"apiVersion": "0.1", | |
"apis": [ | |
{ | |
"description": "Operations about projects", | |
"path": "/project.{format}" | |
}, | |
{ | |
"description": "Operations about tickets", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
convert image.tif -resize 1.5625% -crop 256x256 +repage +adjoin out/1/tile_1_%d.jpg | |
convert image.tif -resize 3.125% -crop 256x256 +repage +adjoin out/2/tile_2_%d.jpg | |
convert image.tif -resize 6.25% -crop 256x256 +repage +adjoin out/3/tile_3_%d.jpg | |
convert image.tif -resize 12.5% -crop 256x256 +repage +adjoin out/4/tile_4_%d.jpg | |
convert image.tif -resize 25% -crop 256x256 +repage +adjoin out/5/tile_5_%d.jpg | |
convert image.tif -resize 50% -crop 256x256 +repage +adjoin out/6/tile_6_%d.jpg | |
convert image.tif -crop 256x256 +repage +adjoin out/7/tile_7_%d.jpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Model | |
class ModelA < ActiveRecord::Base | |
has_many :modelb | |
end | |
class ModelB < ActiveRecord::Base | |
belongs_to :modela | |
has_many :modelc | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index do | |
column :image, :sortable => :image do |model| | |
if model.image.to_s.nil? | |
raw('—') | |
else | |
raw('✓') | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -iname "*.jpg" | perl -e 'for(<>) { chomp $_;@a=split(/\//,$_);$str = "convert -resize 15% -quality 60 $_ _".$a[-1];print $str."\n";`$str`}' |