Skip to content

Instantly share code, notes, and snippets.

View hSATAC's full-sized avatar
🐈
Cataholic

Ash Wu hSATAC

🐈
Cataholic
View GitHub Profile
package main
import (
"fmt"
)
type Node struct {
Value int
}
@hSATAC
hSATAC / import.py
Last active December 21, 2015 13:59
Delicious import from plain txt file.
#!/usr/bin/env python
import httplib2
import time
from urllib import urlencode
add_url = 'https://api.del.icio.us/v1/posts/add?%s'
headers = {'User-Agent': 'Delicious Import'}
bookmarks = [line.strip() for line in open('bookmarks.txt')]
@hSATAC
hSATAC / gist:6198933
Created August 10, 2013 03:29
Make Your Views Fast by Evadne Wu

Make Your Views Fast by Evadne Wu

  • rendering pipeline

  • layer tree(your code) vs presentation tree => pass to render tree

  • blending vs compositing

view 疊太深 => draw into your own buffer <=> against animation

@hSATAC
hSATAC / gist:6170667
Last active December 20, 2015 17:48
Cool Obj-C code snippets.
// weak self
__weak __typeof(&*self)weakSelf = self;

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

[ 2013-07-15 05:20:54.5495 19490/7f05d695c700 Pool2/Spawner.h:723 ]: [App 20216 stdout]
[ 2013-07-15 05:22:00.5540 20666/7f6696b2e740 agents/Watchdog/Main.cpp:424 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/usr/local/rbenv/versions/1.9.3-p448/bin/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_instances_per_app' => '0', 'max_pool_size' => '6', 'passenger_root' => '/usr/local/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/passenger-enterprise-server-4.0.5', 'pool_idle_time' => '300', 'prestart_urls' => 'aHR0cHM6Ly9mYXJpYS5vcGVuYXBwbHkuY29tLwA=', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'user_switching' => 'true', 'web_server_pid' => '20665', 'web_server_type' => 'nginx', 'web_server_worker_gid' => '33', 'web_server_worker_uid' => '33' }
[ 2013-07-15 05:22:00.5664 20669/7fe253499740 agents/HelperAgent/Main.cpp:539 ]: PassengerHelperAgent online, listening at unix:/tm
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin

diff --git a/gc.c b/gc.c
index ace7a08..07b7521 100644
--- a/gc.c
+++ b/gc.c
@@ -253,6 +253,7 @@ typedef struct rb_objspace {
size_t total_allocated_object_num;
size_t total_freed_object_num;
int gc_stress;
+ int gc_disable_lazy_sweep;
@hSATAC
hSATAC / gist:5591270
Last active December 17, 2015 09:59
Shell function to send pull request using hub
# Usage: pr (pull request current branch into develop)
# Usage 2: pr stable (pull request current branch into stable)
# Notice: replace "team" with your github team account.
function pr() {
base=$1;
if [ "$1" == "" ]; then
base="develop"
fi
hub pull-request -b team:"$base" -h team:`git rev-parse --abbrev-ref HEAD`;