Skip to content

Instantly share code, notes, and snippets.

Nihad Abbasov NARKOZ

Block or report user

Report or block NARKOZ

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@NARKOZ
NARKOZ / db_backup.sh
Created Oct 23, 2010
MySQL backup shell script
View db_backup.sh
#!/bin/bash
# Shell script to backup MySQL database
# Set these variables
MyUSER="" # DB_USERNAME
MyPASS="" # DB_PASSWORD
MyHOST="" # DB_HOSTNAME
# Backup Dest directory
DEST="" # /home/username/backups/DB
@NARKOZ
NARKOZ / whitespace.rake
Created Aug 30, 2011
Whitespaaaaaaaace! WHITESPAAAAAAAACE!
View whitespace.rake
# requires BSD sed
namespace :whitespace do
desc 'Removes trailing whitespace'
task :cleanup do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' 's/ *$//g' "$f";
done}, {:verbose => false}
puts "Task cleanup done"
end
View jquery.browser.js.coffee
# Restores `$.browser` functionality removed in jQuery 1.9
jQuery.uaMatch = (ua) ->
ua = ua.toLowerCase()
match = /(chrome)[ \/]([\w.]+)/.exec(ua) or
/(webkit)[ \/]([\w.]+)/.exec(ua) or
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) or
/(msie) ([\w.]+)/.exec(ua) or
ua.indexOf("compatible") < 0 and /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) or []
browser: match[1] or ''
version: match[2] or '0'
@NARKOZ
NARKOZ / gist:4294977
Last active Oct 26, 2015
ImageMagick vs GraphicsMagick (Resizing to Fill a Given Space)
View gist:4294977
# gem 'mini_magick' 5217dfe
# GraphicsMagick 1.3.17
# ImageMagick 6.7.0-10
# Resize to fill (old method)
# http://www.imagemagick.org/Usage/resize/#space_fill
#
# works with ImageMagick as expected
# fails to work with GraphicsMagick as expected
View evaluation.rb
def evaluation_value(reputation_name, source, *args)
scope = args.first
srn = ReputationSystem::Network.get_scoped_reputation_name(self.class.name, reputation_name, scope)
evaluation = RSEvaluation.find_by_reputation_name_and_source_and_target(srn, source, self)
evaluation.present? ? evaluation.value : 0
end
def has_evaluation?(reputation_name, source, *args)
scope = args.first
srn = ReputationSystem::Network.get_scoped_reputation_name(self.class.name, reputation_name, scope)
@NARKOZ
NARKOZ / gist:842156
Created Feb 24, 2011
Apple Store is down, awaiting new 2011 MacBook Pro
View gist:842156
#! /bin/bash
while [[ true ]]; do
STOREDOWN=`curl -s http://store.apple.com/us | grep backsoon`
if [ "$STOREDOWN" = "" ]; then
/usr/local/bin/growlnotify "Apple store is up!" -m "Let' see what's new"
View HTMLStringToDOM.js
/*
* HTMLParser for Greasemonkey by snaka(http://d.hatena.ne.jp/snaka72/)
*
* Original coode written by swdyh(http://d.hatena.ne.jp/swdyh/)
* This code includes part of AutoPagerize(http://userscripts.org/scripts/show/8551)
*
* Released under the GPL license
* http://www.gnu.org/copyleft/gpl.html
*/
View _config.php
<?php
/**********************
*
* Errors / Dev
*
**********************/
//
//Force enviroment to Dev ** REMOVE FOR LIVE SITES **
Director::set_environment_type("dev");
//
You can’t perform that action at this time.