Skip to content

Instantly share code, notes, and snippets.

View fangpenlin's full-sized avatar
🚀

Fang-Pen Lin fangpenlin

🚀
View GitHub Profile
@aldro61
aldro61 / popcount_array.pyx
Last active October 2, 2023 13:07
Popcount of a numpy array of 32-bit integers
"""
Compile with gcc flag -mpopcnt
"""
import numpy as np
cimport numpy as np
cimport cython
from libc.stdint cimport uint32_t, uint8_t
cdef extern int __builtin_popcount(unsigned int) nogil
@gjtorikian
gjtorikian / homepage_spec.rb
Last active December 5, 2019 20:28
Basic Capybara testing with Jekyll + Rack
require 'spec_helper'
describe "Homepage" do
before :each do
visit "/index.html"
end
it "has a title" do
expect(page).to have_css("h1", text: "GitHub Help")
@bdeshong
bdeshong / gist:2dd90add09b7287a9a85
Created August 19, 2014 20:30
Xcode 6 beta 6 iOS 8 simulator errors
8/19/14 4:29:18.557 PM com.apple.CoreSimulator.CoreSimulatorService[22614]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f8e085107e0 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}
8/19/14 4:29:18.557 PM com.apple.CoreSimulator.CoreSimulatorService[22614]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f8e085107e0 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}
8/19/14 4:29:18.557 PM Xcode[52276]: [MT] iPhoneSimulator: Unable to connect to "com.apple.instruments.deviceservice.lockdown" (Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f8a3ad2c5b0 {NSLocalizedDescription=Unable to lookup in current state: Shutdown})
8/19/14 4:29:18.957 PM com.apple.CoreSimulator.CoreSimulatorService[22614]: Error Domain=com.apple.CoreSimulator.SimError Code=142 "The iOS 8.0 simulator runt
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@staltz
staltz / introrx.md
Last active October 26, 2025 03:06
The introduction to Reactive Programming you've been missing
@d-ronnqvist
d-ronnqvist / Thoughts on removedOnCompletion in SparkRecordingCircle.md
Last active May 16, 2020 02:51
What I think is wrong with the Spark Recording Circle code and why

There was [a tweet][tweetSoto] a couple of days ago that resulted in a discussion/question about what it wrong with the usage of removedOnCompletion = NO in the [SparkRecordingCircle code][code] for that [Subjective-C post][post].

We all kept saying that the explanation doesn't fit in a tweet, so here is my rough explanation about the issues.

But, let me first say that I think that the Subjective-C articles are reallt cool and useful to learn from. This is trying to reason about the general usage of removedOnCompletion = NO, using that code as an example, since that was what was discussed on twitter.


The root problem, as [Nacho Soto pointed out][rootProblem], is that removedOnCompletion = NO in combination with fillMode = kCAFillModeForwards is almost always used when you are not updating the model layer. This means that after the animation has finished, what you see on screen is not reflected in the property of the layer. The biggest issue that this can cause is that all the

@kujohn
kujohn / portforwarding.md
Last active June 5, 2025 22:43
Port forwarding in Mavericks

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like:

@tbrianjones
tbrianjones / free_email_provider_domains.txt
Last active October 18, 2025 23:08
A list of free email provider domains. Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
1033edge.com
11mail.com
123.com
123box.net
123india.com
123mail.cl
123qwe.co.uk
126.com
150ml.com
15meg4free.com
@d11wtq
d11wtq / enum.sql
Created October 26, 2012 10:07
Renaming an ENUM label in PostgreSQL
/*
Assuming you have an enum type like this.
You want to rename 'pending' to 'lodged'
*/
CREATE TYPE dispute_status AS ENUM('pending', 'resolved', 'open', 'cancelled');
BEGIN;
ALTER TYPE dispute_status ADD VALUE 'lodged';
UPDATE dispute SET status = 'lodged' WHERE status = 'pending';
@joelverhagen
joelverhagen / clean_py.sh
Created October 8, 2012 16:48
Recursively removes all .pyc files and __pycache__ directories in the current directory
#!/bin/sh
# recursively removes all .pyc files and __pycache__ directories in the current
# directory
find . | \
grep -E "(__pycache__|\.pyc$)" | \
xargs rm -rf
# or, for copy-pasting: