Skip to content

Instantly share code, notes, and snippets.

View seansu4you87's full-sized avatar

Sean Yu seansu4you87

  • Evenly
  • San Francisco, CA
View GitHub Profile
@seansu4you87
seansu4you87 / svn-merge.md
Last active September 30, 2015 10:37
svn merging

svn merge --accept theirs-full -r0:HEAD ./trunk/ ./testing/

merges trunk -> testing, accepting trunk as canon if conflict arises

@seansu4you87
seansu4you87 / KIFStep.m
Last active October 1, 2015 02:38
KIF enter text in UITextField inside UIWebView
If you are the only controlling the HTML, change it so that your input field has default values for accessibility. You can do this via several of the attributes. If you don't have access to the HTML...
You can inject javascript into your webview and change the title attribute of the <input> tags, giving them a default and static accessibilityLabel.
NSString *result = [self.webView stringByEvaluatingJavaScriptFromString:@"var inputs = document.getElementsByTagName('input');"
"for (var index = 0; index < inputs.length; index++){inputs[index].title = 'input ' + index;}"
];
Here I give the nth <input> tag an accessibility label of "input n".
-----BEGIN CERTIFICATE-----
MIIFAzCCA+ugAwIBAgIQGLLLuqME8aAPwfLzJkYqSjANBgkqhkiG9w0BAQUFADCB
gTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G
A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNV
BAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEyMDEwMDAw
MDBaFw0xOTEyMzEyMzU5NTlaMHIxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVh
dGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9E
TyBDQSBMaW1pdGVkMRgwFgYDVQQDEw9Fc3NlbnRpYWxTU0wgQ0EwggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCt8AiwcsargxIxF3CJhakgEtSYau2A1NHf
5I5ZLdOWIY120j8YC0YZYwvHIPPlC92AGvFaoL0dds23Izp0XmEbdaqb1IX04XiR
@seansu4you87
seansu4you87 / fb-js.html
Last active December 19, 2015 15:59
JS Facebook Connect
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOUR_APP_ID', // App ID from the app dashboard
channelUrl : '//localhost:9000/channel.html', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
@seansu4you87
seansu4you87 / account.go
Created March 13, 2014 01:22
Concurrency in Go with Accounts
package main
import (
"errors"
"fmt"
)
type Account struct {
balance int
deltaChan chan int
@seansu4you87
seansu4you87 / geektools-multi-monitor.md
Last active February 17, 2024 04:29
GeekTools Multi Monitor Reposition

Geektools with Varying Monitor Setups

While I love my Geeklets, I had a pretty hard time to set them up consistently across varying monitor setups (home, work, on the go,...). The bad news first: There is no built in mechanism (as of 01/2013) to take care of this problem. Still there are good news: With some minor tinkering, you can automagically position your Geeklets across multiple setups.

The initial step is to add your Geeklets - you can totally ignore the positioning for the moment.

Which Geeklets Am I Running?

@seansu4you87
seansu4you87 / executor.rb
Created April 24, 2014 00:05
Using Executor in jruby
# Start the executor service. Note that this won't create any threads right away,
# but will create new threads as the jobs are submitted, until it gets to 5 threads.
# Then it will reuse the threads.
executor = java.util.concurrent.Executors.newFixedThreadPool(5)
# Submit jobs, get back java.util.concurrent.FutureTask objects.
future_tasks = [1, 2, 3, 4, 5, 6].map do |number|
executor.submit do
puts "starting work"
sleep(10)

This is my recommended path for learning Haskell.

Something to keep in mind: don't sweat the stuff you don't understand immediately. Just keep moving.

Primary course

http://www.seas.upenn.edu/~cis194/lectures.html Brent Yorgey's course is the best I've found so far and replaces both Yann Esposito's HF&H and the NICTA course. This course is particularly valuable as it will not only equip you to write Haskell but also help you understand parser combinators.

Exercises for practice

@seansu4you87
seansu4you87 / robyn-hack
Created June 2, 2014 01:16
Hack for Robyn
require 'httparty'
URL = "http://ci.uky.edu/dev/venture-challenge/api/venture/upvote"
def upvote_robyn
response = HTTParty.post URL, { body: {:id => 11} }
puts response
end
while true
@seansu4you87
seansu4you87 / taqueria.hs
Created August 1, 2014 00:31
Haskell for Taquerias
foo :: Int
foo = 5
incr :: Int -> Int
incr x = x + 1
decr :: Int -> Int
decr x = x - 1
nada :: Int -> Int