Skip to content

Instantly share code, notes, and snippets.

View ichord's full-sized avatar

lhl ichord

  • Anywhere the Internet is
View GitHub Profile
@tadija
tadija / AECoreData.swift
Last active June 19, 2022 15:34
AECoreData
/**
* https://gist.github.com/tadija/6003830264d67a87193ff0c3d20373e7
* Revision 10
* Copyright © 2018-2021 Marko Tadić
* Licensed under the MIT license
*/
import CoreData
@available(iOS 10.0, *)
defmodule StrongParams do
def extract(params, allowed_fields, atomize \\ false)
def extract(params, allowed_fields, atomize) when not is_list(allowed_fields),
do: extract(params, [allowed_fields], atomize)
def extract(params, allowed_fields, atomize)
when is_map(params) and is_list(allowed_fields) do
Enum.reduce(allowed_fields, %{}, fn field, acc ->
case extract_field(field, params, atomize) do
@dnnta
dnnta / city.rb
Created April 20, 2017 09:56
中国城市列表整理
# 数据来源 http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201703/t20170310_1471429.html
# 截止 2016 年 7 月 31 日
# 4 个直辖市下面的市辖区手动处理, 改为对应的名字,如 北京市-市辖区 改为 北京市-北京
# 其他市辖区, 直接去掉, 不入库
# 还有 4 个省直辖县级行政区划也手动处理, 去掉层级关系
class CreateChinaCities < ActiveRecord::Migration[5.0]
def change
create_table :china_cities do |t|
t.integer :code, index: true
@higepon
higepon / API.swift
Last active July 31, 2023 16:00
An example of JSON API call in Swift
//
// API.swift
//
// Created by Taro Minowa on 6/10/14.
// Copyright (c) 2014 Higepon Taro Minowa. All rights reserved.
//
import Foundation
typealias JSONDictionary = Dictionary<String, AnyObject>
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.
@maccman
maccman / jquery.ajax.queue.coffee
Last active January 13, 2018 12:03
Queueing jQuery Ajax requests. Usage $.ajax({queue: true})
$ = jQuery
queues = {}
running = false
queue = (name) ->
name = 'default' if name is true
queues[name] or= []
next = (name) ->
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@tobscher
tobscher / custom_plan.rb
Created January 30, 2013 15:39
Zeus engine setup.
require 'zeus/rails'
ROOT_PATH = File.expand_path(Dir.pwd)
ENV_PATH = File.expand_path('spec/dummy/config/environment', ROOT_PATH)
BOOT_PATH = File.expand_path('spec/dummy/config/boot', ROOT_PATH)
APP_PATH = File.expand_path('spec/dummy/config/application', ROOT_PATH)
ENGINE_ROOT = File.expand_path(Dir.pwd)
ENGINE_PATH = File.expand_path('lib/my_engine/engine', ENGINE_ROOT)
class CustomPlan < Zeus::Rails
@minikomi
minikomi / editor.html
Last active November 11, 2021 10:16
my editor
data:text/html,
<style type="text/css">
#e {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
font-size:16px;
}
@paulmillr
paulmillr / Gruntfile.js
Created September 11, 2012 10:11
yeoman default config
module.exports = function( grunt ) {
'use strict';
//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.initConfig({
// Project configuration