Skip to content

Instantly share code, notes, and snippets.

View shinyzhu's full-sized avatar
🗣️
Talk to me

Shiny shinyzhu

🗣️
Talk to me
View GitHub Profile
var z="http://gist.github.com/",y=document.write,x=$("body"),w=$("p.gist").map(function(b,a){a=$(a);var c=$("a",a),u=c.attr("href");if(c.length&&u.indexOf(z)==0)return{p:a,id:u.substring(z.length)}}).get(),v=function(){if(w.length==0)document.write=y;else{var b=w.shift();document.write=function(){document.write=function(a){b.p.replaceWith(a);v()}};x.append('<scr'+'ipt src="'+z+b.id+'.js"></scr'+'ipt>')}};v();
@shinyzhu
shinyzhu / gist:3175082
Created July 25, 2012 08:27
UIColor from hex value in Objective-C
/*
UIColor from hex value in Objective-C
*/
#define UIColorFromRGB(rgbHex) [UIColor colorWithRed:((float)((rgbHex & 0xFF0000) >> 16))/255.0 green:((float)((rgbHex & 0xFF00) >> 8))/255.0 blue:((float)(rgbHex & 0xFF))/255.0 alpha:1.0]
// Usage:
UIColor *bgColor = UIColorFromRGB(0xCCEEFF);
@shinyzhu
shinyzhu / gist:2601241
Created May 5, 2012 09:50
NSLog replacement
// NSLog replacement
#define MYLogEnabled NO
#define MYLog(format, ...) \
if(MYLogEnabled){NSLog(@"%s: (Ln%i) %@", __PRETTY_FUNCTION__, __LINE__, [NSString stringWithFormat:format, ## __VA_ARGS__]);}
@shinyzhu
shinyzhu / dabblet.css
Created February 18, 2012 05:40
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
body{background: linear-gradient(45deg, #f06, yellow);min-height: 100%;}
canvas{width:600px;height:400px;background:#cef;}
@shinyzhu
shinyzhu / inheritance.js
Created February 10, 2012 06:45
Inheritance in javascript
// Practices from Object Oriented Javascript
// version 0.0.0.11
(function() {
function multi() {
var n = {},
stuff, j = 0,
len = arguments.length;
for (j = 0; j < len; j++) {
stuff = arguments[j];
for (var i in stuff) {
@shinyzhu
shinyzhu / ipin.py
Created October 8, 2011 02:37
iPIN - iPhone PNG Images Normalizer
#---
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007
#
# Author:
# Axel E. Brzostowski
# http://www.axelbrz.com.ar/
# axelbrz@gmail.com
#
# References:
@shinyzhu
shinyzhu / Base58Encoder.h
Created July 8, 2011 03:16
ObjC implementation of base 58 encoding for Flic.kr URLs.
@interface Base58Encoder : NSObject {
}
+ (NSString *)base58EncodedValue:(long long)num;
@end
@shinyzhu
shinyzhu / gist:836796
Created February 21, 2011 08:01
read info.plist
NSBundle *mainBudle=[NSBundle mainBundle];
NSString *hgURL = [mainBudle objectForInfoDictionaryKey:@"HGGuideURL"];
<!-- set these 2 attributes to hide secondary y-axis value in mscombidy2d.swf of FusionCharts -->
<chart showDivLineSecondaryValue="0" showSecondaryLimits="0">
</chart>
@shinyzhu
shinyzhu / gist:552657
Created August 27, 2010 02:25
DAL for SAE
<?php
/*
Data Access Layer for FansWall(http://fanswall.sinaapp.com)
Author: Shiny Zhu(http://t.sina.com.cn/shinyzhu)
*/
class DAL{
private $server, $username, $password, $db;
private $link;
private $result;