Skip to content

Instantly share code, notes, and snippets.

View quanganhdo's full-sized avatar

Anh Do quanganhdo

View GitHub Profile
@quanganhdo
quanganhdo / gist:5430596
Created April 21, 2013 18:50
cmus is running
ps aux | grep -w "cmus$"
@quanganhdo
quanganhdo / gist:5430594
Created April 21, 2013 18:50
Next Track
/usr/local/bin/cmus-remote -n
@quanganhdo
quanganhdo / gist:5430592
Created April 21, 2013 18:49
Previous Track
/usr/local/bin/cmus-remote -r
@quanganhdo
quanganhdo / brew-cask.rb
Created October 10, 2012 05:29 — forked from phinze/brew-cask.rb
a homebrew formula for installing brew-cask
require 'formula'
class BrewCask < Formula
homepage 'https://github.com/phinze/brew-cask/'
head 'git://github.com/patrickkettner/brew-cask.git'
skip_clean :all
def install
/*
* System Versioning Preprocessor Macros (by mwaterfall)
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
javascript:eval(function(p,a,c,k,e,d){e=function(c){return%20c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return%20d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new%20RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return%20p}('g%20f(){6(j.h)7%20j.h;6(9.e&&9.e.a)7%209.e.a;6(9.l.a)7%209.l.a;7%200}g%20q(){2%204=f();2%201=0;2%20b=4;6(b<k){d(0,1);7}2%20c=p.r(b/k);2%205=p.r(b/s);2%203=1>4?4+5:4-5;2%208=0;6(1>4){m(2%20i=4;i<1;i+=5){n("o.d(0,%20"+3+")",8*c);3+=5;6(3>1)3=1;8++}7}m(2%20i=4;i>1;i-=5){n("o.d(0,%20"+3+")",8*c);3-=5;6(3<1)3=1;8++}}q();',29,29,'|stopY|var|leapY|startY|step|if|return|timer|document|scrollTop|distance|speed|scrollTo|documentElement|currentYPosition|function|pageYOffset||self|100|body|for|setTimeout|window|Math|smoothScroll|round|25'.split('|'),0,{}))
<?php
/**
* A little Object Relational Mapper in PHP
* @author dennis.hotson@gmail.com
*/
class Post
{
public $title;
- (void)savePhotoOfView:(UIView *)view
{
UIGraphicsBeginImageContext(view.bounds.size);
[view drawRect:view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(savedPhotoImage:didFinishSavingWithError:contextInfo:),
+ (UIImage *)imageWithColor:(UIColor *)color width:(float)width height:(float)height {
CGRect rect = CGRectMake(0.0f, 0.0f, width, height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_fields));
$header = curl_exec($ch);
curl_close($ch);
?>