Skip to content

Instantly share code, notes, and snippets.

@Krishna
Krishna / itunesicon.rb
Created October 28, 2017 17:36 — forked from ttscoff/itunesicon.rb
Retrieve a 512 x 512px icon for an iOS app
#!/usr/bin/ruby
# encoding: utf-8
#
# Updated 2017-10-25:
# - Defaults to large size (512)
# - If ImageMagick is installed:
# - rounds the corners (copped from @bradjasper, https://github.com/bradjasper/Download-iTunes-Icon/blob/master/itunesicon.rb)
# - replace original with rounded version, converting to png if necessary
#
# Retrieve an iOS app icon at the highest available resolution
@Krishna
Krishna / README.md
Created March 9, 2016 23:06 — forked from nikcub/README.md
Facebook PHP Source Code from August 2007
@Krishna
Krishna / EmployeesController.rb
Last active February 5, 2016 20:17
Problems with routing based on roles of a User model
class EmployeesController < ApplicationController
before_action :authenticate_user!
before_action :set_employee, only: [:show, :edit, :update, :destroy]
def index
@employees = current_user.employees.all # I guess the problem is that this returns a collection
# of User objects. But the url_helper will expect objects
# of class Employee (which does not exist).
end

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@Krishna
Krishna / Output from curl...
Last active August 29, 2015 14:15
Sinatra caching problem
➜ Sinatra Lab curl -v http://localhost:4567/cache
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 4567 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4567 (#0)
> GET /cache HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:4567
> Accept: */*
def open_links_in_safari(project_links)
project_links_arguments = project_links.join(" ") # project_links in an array of url strings
cmd_line = "osascript newsafariwindow.scpt #{project_links_arguments}"
system(cmd_line)
end
(swift)
(swift) func greet(name :String) -> String
{ return "hello /(name)" }
(swift)
(swift) greet
// r0 : (String) -> String = (Function)
(swift)
(swift) var temp = [greet]
// temp : Array<(String) -> String> = [(Function)]

I like Learn You a Haskell as a reference and cheat-sheet but I found it a little slow for learning Haskell.

Here's my recommended order for just learning Haskell:

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.

Real World Haskell is available online. (Thanks bos!)

I recommend RWH as a reference (thick book). The chapters for parsing and monads are great for getting a sense for where monads are useful. Other people have said that they've liked it a lot. Perhaps a good follow-up for practical idioms after you've got the essentials of Haskell down?

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/
  Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep -H UI_APPEARANCE_SELECTOR ./* | sed 's/ __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0) UI_APPEARANCE_SELECTOR;//'

UIActivityIndicatorView

//
// StickyHeaderLayout.h
// Wombat
//
// Created by Todd Laney on 1/9/13.
// Copyright (c) 2013 ToddLa. All rights reserved.
//
// Modified from http://blog.radi.ws/post/32905838158/sticky-headers-for-uicollectionview-using THANKS!
//