Skip to content

Instantly share code, notes, and snippets.

//
// NSMutableArray+Pop.h
// Foo
//
// Created by leafduo on 2/11/13.
// Copyright (c) 2013 leafduo.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@leafduo
leafduo / tsocks.rb
Last active December 11, 2015 03:39
require 'formula'
class Tsocks < Formula
# The original is http://tsocks.sourceforge.net/
# This GitHub repo is a maintained fork with OSX support
homepage 'http://github.com/pc/tsocks'
head 'https://github.com/pc/tsocks.git'
depends_on 'autoconf' => :build if MacOS.xcode_version.to_f >= 4.3
[self addObserverForKeyPath:@"myComment" task:[](id obj, NSDictionary *change) {
[self->_myCommentButton setTitle:self.myComment forState:UIControlStateNormal];
}];
__weak typeof(self) bself = self;
[self addObserverForKeyPath:@"myComment" task:^(id obj, NSDictionary *change) {
__strong typeof(bself) cself = bself;
[cself->_myCommentButton setTitle:self.myComment forState:UIControlStateNormal];
}];
UIImage* resizableImageWithCapInsets(id self, SEL _cmd, UIEdgeInsets capInsets) {
return [self stretchableImageWithLeftCapWidth:capInsets.left topCapHeight:capInsets.top];
}
- (void)addMissingMethod {
if (![UIImage instancesRespondToSelector:@selector(resizableImageWithCapInsets:)]) {
class_addMethod([UIImage class], @selector(resizableImageWithCapInsets:), (IMP) resizableImageWithCapInsets, "@@:{top=CGFloat, left=CGFloat, bottom=CGFloat, right=CGFloat");
}
}
@leafduo
leafduo / gist:3207505
Created July 30, 2012 14:52
Disqus migration
list = File.open('old.cvs')
list.each do |line|
new_path = `find . -iname "*#{line.split('/')[-2]}.html"`
new_path.slice!(0...2)
new_path.slice!(".html")
new_path[4] = new_path[7] = new_path[10] = '/'
new_path.strip!
new_path = "http://testing.leafduo.com/#{new_path}/"
puts "#{line.strip}, #{new_path}"
#include <stdio.h>
int main()
{
FILE * fout = fopen("output.txt", "w");
int i;
for (i = 0; i < 1e6; ++i)
fprintf(fout, "%d", 0);
return 0;
}
class Class:
pass
def say_hello(self):
print "Hello"
Class.say_hello = say_hello
Class().say_hello()
有道理是要有依据的,不是你说有道理就有道理。
http://www.nejm.org/doi/full/10.1056/NEJMoa040576#t=abstract 是文章里说的 “2004年10月《新英格兰医学杂志》发表一篇牛奶致女性乳腺癌的研究报告”,里面确实是研究乳腺癌的影响因素,但是全文没有提到牛奶(也可能是我漏了),全篇在研究青春期时候的 BMI、生长速度之类,论文的结论是 Birth weight and growth during childhood and adolescence influence the risk of breast cancer.
IGF-I 确实跟癌症有关,不过这篇论文只字未提。http://en.wikipedia.org/wiki/Insulin-like_growth_factor_1
维基百科里提到了 Some studies suggest that milk consumption may increase the risk of suffering from certain health problems.
注意其中的措辞,再比较文章开头“牛奶危害健康,是当代世界新营养学的共识。”哪里成共识了?
coreStorage | cs coreStorageVerb [...]
CoreStorage verbs can be used to create, manipulate and
destroy CoreStorage volumes.
CoreStorage maintains a world of virtual disks, somewhat like
RAID, in which one can easily add or remove imported backing
store disks, as well as exported usable volumes, to or from a
pool (or several pools). This provides the user with flexibil-
ity in allocating their hardware; user or operating system
data can span multiple physical disks seamlessly, for example.