Skip to content

Instantly share code, notes, and snippets.

dnnta / city.rb
Created Apr 20, 2017
View city.rb
# 数据来源
# 截止 2016 年 7 月 31 日
# 4 个直辖市下面的市辖区手动处理, 改为对应的名字,如 北京市-市辖区 改为 北京市-北京
# 其他市辖区, 直接去掉, 不入库
# 还有 4 个省直辖县级行政区划也手动处理, 去掉层级关系
class CreateChinaCities < ActiveRecord::Migration[5.0]
def change
create_table :china_cities do |t|
t.integer :code, index: true
dnnta /
Created Jun 17, 2019 — forked from anotheruiguy/
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

dnnta / svn
Created Jun 18, 2012
mac 删除svn文件
View svn
有时复制一个已经存放在svn的项目时,会把里面的svn文件也复制了过去。所以再次提交到svn时会出现 under version control.
sudo find /Applications/MAMP/htdocs/jumpqsina/ -name ".svn" -exec rm -r {} \;
dnnta / gist:2593453
Created May 4, 2012
contentInset contentSize和contentOffset区别
View gist:2593453
contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),
contentoffset就是(0 ,480),也就是y偏移了480
contentInset是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示
dnnta / run script
Created Sep 26, 2016
target run script
View run script
cp -rf "${resources_path}/${TARGET_NAME}.app" "${BUILT_PRODUCTS_DIR}/"
chmod 777 "${BUILT_PRODUCTS_DIR}/${TARGET_NAME}.app/YXLiveVideoApp"
View gist:744aa9a7bf5f26560545
#define _DD_MACRO_SELF_STR(macro) #macro
#define _DD_MACRO_TO_STR(macro) _DD_MACRO_SELF_STR(macro)
#define DD_LOG_MACRO(macro) NSLog(@"\n%s\n%s", #macro, _DD_MACRO_TO_STR(macro))
dnnta / gist:4971848
Created Feb 17, 2013
View gist:4971848
static bool debuggerRunning(void)
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
info.kp_proc.p_flag = 0;
mib[0] = CTL_KERN;
dnnta / NSDictionary.h
Created Jan 9, 2013
Compare two NSDictionary
View NSDictionary.h
-(BOOL)isEtalonDictionary:(NSDictionary *)etalonDictionary sameAs:(NSDictionary *)dictionary{
BOOL res = NO;
for (id item in etalonDictionary){
NSObject *secondObject = [dictionary objectForKey:item];
if (secondObject == nil)
return NO;
NSObject *value = [etalonDictionary objectForKey:item];
if ([value isKindOfClass:[NSString class]]){
NSString *string = (NSString *) value;
dnnta / gist:4351830
Last active Dec 10, 2015
View gist:4351830
NSString *htmlStr = @"This is a <br />string with html <strong>tag</strong>.";
NSRange range;
while ((range = [htmlStr rangeOfString:@"< [^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound){
htmlStr = [htmlStr stringByReplacingCharactersInRange:range withString:@""];
<p [stylealign]{5}=".*?">.*?<img.*?src="(.*?)".*?/>.*?</p>[\r\n]+<p [stylealign]{5}=".*?">[\r\n\s]*?(.*?)</p>
View graphic_util.h
* graphic_util.h
* radikker
* Created by saiten on 09/11/26.
* Copyright 2009 __MyCompanyName__. All rights reserved.
#ifndef __SYUN_GRAPHICS_H__