Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

JG tlkahn

🥫
View GitHub Profile
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]]];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor blueColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, screenWidth-50, screenWidth-50, 50)];
label.backgroundColor = [UIColor whiteColor];
label.text = @"hello world";
[imageView addSubview:label];
@tlkahn
tlkahn / main.cpp
Created October 5, 2016 07:25
create a closure in C++
struct db_sum: public std::unary_function<boost::any, void> {
private:
double& sum_;
public:
explicit db_sum(double& sum)
: sum_(sum)
{}
void operator()(const cell_t& value) {
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)
;;(package-refresh-contents)
(require 'ido)
(ido-mode t)
(require 'package)
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
;; (package-refresh-contents)
@tlkahn
tlkahn / vimregex-juan_auras_lester.md
Created March 15, 2017 13:33 — forked from dreftymac/vimregex-juan_auras_lester.md
vim regular expressions for perl regex fans

Overview

Vim regular expressions are powerful, but they pre-date Perl.

This can be frustrating since the Perl-flavored-regex syntax has expanded beyond into other programming languages and contexts, becoming a de-facto standard.

This guide is a quick cheatsheet and tipsheet for using regular expressions in Vim for those who may be more familiar with Perl.

Quick examples for vimmers who like Perl regex

@tlkahn
tlkahn / gist:01c304891e5aa6d7562feb0857a81811
Last active June 14, 2017 04:23
hackerland-radio-transmitters
def solution(k, arr, origin=0):
arr.sort()
result = 1
cur = 0
origin = 0
for i in range(1, len(arr)):
if arr[i] - arr[origin] <= k:
pass
else:
@tlkahn
tlkahn / gist:4b26ddbba4cb63ff5f9c8418b61febd8
Created June 14, 2017 05:53
Hackerland Radio Transmitters python
def solution(k, arr, origin=0):
arr = sorted(list(set(arr)))
result = 1
cur = 0
origin = 0
for i in range(1, len(arr)):
f = False
if arr[i] - arr[origin] <= k:
@tlkahn
tlkahn / test.py
Created June 14, 2017 05:56
hackerrank playground
# hackerrank playground
import pdb
import sys
# def solve(*args):
# result = [0, 0]
# a_ = [args[i] for i in range(int(len(args)/2))]
# b_ = [args[i] for i in range(int(len(args)/2), len(args))]
# pairs = zip(a_, b_)
@tlkahn
tlkahn / function_invocation.js
Created June 18, 2017 20:44 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);