Skip to content

Instantly share code, notes, and snippets.

View karagraysen's full-sized avatar

K. G. karagraysen

View GitHub Profile
@cmelchior
cmelchior / github_issue_rankings.rb
Last active March 7, 2022 18:58
Small ruby script that will rank all Github issues in a repo according to which is the most popular
#!/usr/bin/ruby -w
#
# This script will analyze a Github repo and try to rank all open issues with regard to popularity.
# WARNING: This script will run quite a few HTTP requests against Github to do this analysis. At least 1 pr. issue.
# The current limit on Github is 5000 requests pr. hour: https://developer.github.com/v3/rate_limit/
#
# Usage: ./ruby github-issue-rankings.rb <github_user/repo> <github_api_access_token>
# Example: ruby github_issue_rankings.rb realm/realm-java $GITHUB_ISSUE_RANKINGS_ACCESS_TOKEN
#
# The algorithm for ranking issues are the following:
@albertstartup
albertstartup / cat.js
Created January 2, 2016 05:57
append to a tumblr post from the command line
var Q = require('q');
var tumblr = require('tumblr.js');
var fs = require('fs');
var _ = require('underscore');
// Customize these. Ill give instructions soon. Or ping me for help.
var tumblrClient = tumblr.createClient({
consumer_key: '',
consumer_secret: '',
token: '',
//
// SMetadata.swift
// SimpleMusic
//
// Created by Atharva Vaidya on 09/08/15.
// Copyright (c) 2015 Atharva Vaidya. All rights reserved.
//
import Cocoa
import AVFoundation
@hirad
hirad / RPNSolver
Last active April 29, 2017 18:03
A Simple RPN Calculator in Swift
struct Stack<T> {
let values: [T]
init(_ v: [T] = [T]()) {
self.values = v
}
func push(elem: T) -> Stack<T> {
let newValues = [elem] + self.values
return Stack<T>(newValues)
@rbobbins
rbobbins / protocols.md
Last active June 11, 2024 22:11
Notes from "Protocol-Oriented Programming in Swift"

PS: If you liked this talk or like this concept, let's chat about iOS development at Stitch Fix! #shamelessplug

Protocol-Oriented Programming in Swift

Speaker: David Abrahams. (Tech lead for Swift standard library)

  • "Crusty" is an old-school programmer who doesn't trust IDE's, debuggers, programming fads. He's cynical, grumpy.

  • OOP has been around since the 1970's. It's not actually new.

  • Classes are Awesome

    • Encapsulation
    • Access control
@Goos
Goos / MKPolygon+Containment.h
Last active January 22, 2017 22:25
A category for checking whether or not an MKPolygon contains a point or coordinate.
//
// MKPolygon+Containment.h
// Pods
//
// Created by Robin Goos on 28/04/15.
//
//
#import <MapKit/MapKit.h>
@sohelsd
sohelsd / UIActivity WhatsApp
Last active January 21, 2023 23:13
WhatsApp Swift UIActivityViewController Custom UIActivity
How to add WhatsApp to UIActivityViewController?
Drop the Whatsapp.swift file in your project.
Initialize the controller as described in ViewController.swift
@JadenGeller
JadenGeller / Init Bool With Int.swift
Created March 23, 2015 07:48
Cast Int to Bool in Swift
extension Bool {
init<T : IntegerType>(_ integer: T){
self.init(integer != 0)
}
}
// Now you can do this
let x = Bool(5) // true
let y = Bool(-1) // true
let z = Bool(0) // false
@JadenGeller
JadenGeller / Swift Chain Function.swift
Last active June 6, 2018 05:37
Swift Chain Function
/*
* chain takes in any number of 1-argument functions as arguments
* and returns a function that executes each function in order
*/
func chain<T>(all: T -> () ...) -> T -> () {
return { x in
for f in all { f(x) }
}
}
@JadenGeller
JadenGeller / Swift Attempt Function.swift
Last active August 29, 2015 14:16
Swift Attempt Function
/*
* attempt takes a function that does not accept optional values
* and returns a new function that will work as usual with non-optional values
* and return nil when passed an optional value
*/
func attempt<T,U>(f: T -> U)-> T? -> U? {
return { y in
if let x = y {
return f(x)