Skip to content

Instantly share code, notes, and snippets.

View guange2015's full-sized avatar

gg guange2015

  • usa
View GitHub Profile
@guange2015
guange2015 / gist:867937
Created March 13, 2011 06:54
vmware fusion
YU2NJ-JVGKY-44N8R-H8Q5Y-0PGE3 3YT81-KJMJR-04WHY-KMU72-KLNEE
@guange2015
guange2015 / gist:2258904
Created March 31, 2012 03:11
instance_exec vs class_exec
# encoding: utf-8
# different instance_exec whit class_exec
class O
def self.haha
puts 'haha'
end
end
O.instance_exec {
- (void)viewDidLoad
{
[super viewDidLoad];
[webView setBackgroundColor:[UIColor clearColor]];
[self hideGradientBackground:webView];
[webView loadHTMLString:@"This is a completely transparent UIWebView. Notice the missing gradient at the top and bottom as you scroll up and down." baseURL:nil];
}
@guange2015
guange2015 / Get iOS MAC address.m
Created May 16, 2012 03:40 — forked from Coeur/Get iOS MAC address.m
Get iOS MAC address #
/* Original source code courtesy John from iOSDeveloperTips.com */
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
- (NSString *)getMacAddress
{
int mgmtInfoBase[6];
@guange2015
guange2015 / static_server.js
Created May 18, 2012 01:32 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@guange2015
guange2015 / gist:2758331
Created May 20, 2012 14:39
Gemfile 3.2.3
source 'http://ruby.taobao.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3', '1.3.5'
@guange2015
guange2015 / gist:2758432
Created May 20, 2012 15:07
bootstrap common template.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
@guange2015
guange2015 / gist:2760931
Created May 21, 2012 07:22
plist 读取与写入
//系统
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleVersion"];
//写入
NSMutableDictionary* dict = [ [ NSMutableDictionary alloc ] initWithContentsOfFile:@"/Sample.plist" ];
[ dict setObject:@"Yes" forKey:@"RestartSpringBoard" ];
[ dict writeToFile:@"/Sample.plist" atomically:YES ];
//读取
@guange2015
guange2015 / user_spec.rb
Created May 25, 2012 13:13
user_spec.rb
require 'spec_helper'
describe User do
subject {@user}
before {@user = User.new(name:'ExampleUser', email:'hah@gmail.com',
password: 'foobar', password_confirmation:'foobar') }
it {should be_valid}
it {should respond_to(:name)}
it {should respond_to(:email)}
@guange2015
guange2015 / authentication_pages_spec.rb
Created May 25, 2012 13:13
authentication_pages_spec.rb
require 'spec_helper'
describe "AuthenticationPages" do
subject {page}
describe "login" do
before {visit login_path}
describe "visit login page" do
it{should have_selector('h1', text:'login')}
end