Skip to content

Instantly share code, notes, and snippets.

View hlfcoding's full-sized avatar
🇺🇦

Peng Wang hlfcoding

🇺🇦
View GitHub Profile
@hlfcoding
hlfcoding / wikipedia-2015.user.css
Created December 6, 2015 10:12
For those who've donated the previous year(s) and don't want to be bothered on each page view with no recourse in the actual UI, which is btw a totally rude UX thing to do.
.frbanner {
display: none;
}
#mw-page-base {
margin-top: 0;
}
@hlfcoding
hlfcoding / !nationbuilder-ios-compact-example.md
Last active March 17, 2016 03:13
Compact Example Using NationBuilder iOS SDK
@hlfcoding
hlfcoding / !nationbuilder-ios-with-swift.md
Last active March 17, 2016 03:11
Using NationBuilder iOS SDK with Swift

Using NationBuilder iOS SDK with Swift

Additional Steps

  1. Put use_frameworks! in your Podfile. Use pod 'NBClient', '~> 1.3.0'. Re-run Cocoapods.
  2. Add bridging header to your project. See [guide].
  3. Refer to the same AppDelegate source to continue.

Caveats

@hlfcoding
hlfcoding / jquery-fn-wait.js
Created February 5, 2015 10:47
jQuery.fn.wait
// jQuery.fn.wait
// Copyright 2015 pengxwang.com
// Released under the MIT license
/*
$.fn.wait = (args...) ->
d = $.Deferred()
k = "wait-#{id}-promise"
p = d.promise()
if args.length is 1
@hlfcoding
hlfcoding / spec.md
Created February 4, 2015 19:35
StateMachine
  • StateMachine
    • #constructor
      • should allow setting initialState
      • should allow registering State's
      • should allow registering Transition's, and a fallback Transition
    • #switchState
      • should allow switch between available State's
      • should perform a transition before calling #onEnter on new state
      • should return a promise, done or fail
  • should emit an event, done or fail
@hlfcoding
hlfcoding / Learn CSS the Hard Way.md
Last active March 16, 2023 19:16
Learn CSS the Hard Way - Example-driven talk that focuses in-depth on CSS2 fundamentals and best practices for real-world scenarios. Examples are interactive. There are also resources (below) for further learning. Everything is online for future reference and experimentation: http://codepen.io/collection/XOLJBj

Introduction (5min)

  • (Setup: http://codepen.io/hlfcoding/pen/vEzpVd, stopwatch, printout of this, all pens loaded.)
  • Reason for this talk: better 'general knowledge of' (will be less lost) / 'fundamental knowledge how to' (will do it right).
  • Format of the talk. Provide general outline. Q&A time after each point.
  • History and personal history with CSS.
    • How complexity has been introduced in places and resolved in others.

Topics

@hlfcoding
hlfcoding / find_closest_prime.py
Last active August 29, 2015 14:02
Given a number, find its closest prime number.
from math import sqrt
def is_prime(n):
print 'Checking {}'.format(n)
if n == 1: return True
root = sqrt(n)
if root % 1 == 0:
print "{} isn't prime, with square root of {}".format(n, root)
return False
try_factor = 2
allSquaredPairs = (num) ->
isInt = (num) -> num % 1 is 0
pairs = []
floor = 0
ceiling = Math.ceil Math.sqrt(num)
for x in [floor...ceiling]
numX = Math.pow x, 2
numY = num - numX
y = Math.sqrt numY
if y >= x and isInt(y)
@hlfcoding
hlfcoding / quick_sort_comparisons.py
Created May 26, 2014 07:44
Coursera Algo-005 Programming Question Set 2
from math import floor
from sys import setrecursionlimit
setrecursionlimit(1000000)
"""
Use quick sort to explore pivoting rules.
TODO: Not working.
"""
@hlfcoding
hlfcoding / merge_sort_inversions.py
Last active August 29, 2015 14:01
Coursera Algo-005 Programming Question 1
"""
Use merge sort to count inversions.
"""
with open('IntegerArray.txt') as f:
ints = [int(line) for line in f.readlines()]
#print 'First 5 ints:{}'.format(ints[:5:])
inversions = 0