Skip to content

Instantly share code, notes, and snippets.

View berkus's full-sized avatar
🎯
Practice your desensitization exercises to remain unfazed by enemy atrocities

Berkus Decker berkus

🎯
Practice your desensitization exercises to remain unfazed by enemy atrocities
View GitHub Profile
@giuseppebarba
giuseppebarba / gist:10149352
Last active March 22, 2018 14:25
Android Debugging
Some system properties:
--------------------------------------------------------------------------------
setprop debug.db.uid 32767
That will cause the crash catcher (debuggerd) to freeze the process,
allowing you to use gdb/gdbserver to debug it.
In the source tree, after you "source build/envsetup.sh" and use
"lunch" or "choosecombo", you will have a shell command called
"gdbclient". By default, it expects to debug "app_process" on port
anonymous
anonymous / client
Created March 31, 2014 23:16
# Эта приблуда - клиент, который получает время с удаленной машины
# Смотреть будем на миллисекунды
require 'net/http'
measures = []
roundtrips = []
uri = URI.parse "http://сервервремени:2000"
# Спецификация NTP какбэ рекомендует спрашивать время несколько раз, минимум 8.
@nikolaykasyanov
nikolaykasyanov / RAC-generator.m
Last active August 29, 2015 13:57
Poor man's generator using ReactiveCocoa 3.0
static RACSignal *BodyImageURLs(NSString *postBody)
{
NSRange (^lastRangeFromMatch)(NSTextCheckingResult *) = ^(NSTextCheckingResult *match) {
if (match == nil) {
return NSMakeRange(NSNotFound, 0);
}
else {
return [match rangeAtIndex:match.numberOfRanges - 1];
}
};
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 10, 2025 09:21
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@jspahrsummers
jspahrsummers / ImageLoading.m
Last active December 29, 2015 03:59
Using -flatten:withPolicy: (from ReactiveCocoa 3.0) and related operators to deal with producers that can outstrip consumers
// Asynchronously loads UIImages from the given URLs, but throttles the loading
// to keep memory and CPU usage sane.
- (RACSignal *)loadImagesAtURLs:(NSArray *)imageURLs {
// Map each URL to a signal of work. The result is a signal of work signals.
return [[imageURLs.rac_signal
map:^(NSURL *imageURL) {
return [[[[NSURLConnection
// Load the URL asynchronously.
rac_sendAsynchronousRequest:[NSURLRequest requestWithURL:imageURL]]
reduceEach:^(NSURLResponse *response, NSData *data) {
@rsobik
rsobik / boost.sh
Created November 17, 2013 13:20
Build Boost 1.55.0 for iOS 7 and OS X including 64 Bit
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for the iPhone.
# Creates a set of universal libraries that can be used on an iPhone and in the
@staltz
staltz / gist:7473252
Last active May 6, 2024 03:15
Code glossary

Code glossary

A useful list of programming jargon to solve your naming problems.

Adapter: a design pattern that translates one interface for a class into a compatible interface.

Admin: short for 'administrator'; very commonly used in speech or online to refer to the systems person in charge on a computer. Common constructions on this include sysadmin and site admin (emphasizing the administrator's role as a site contact for email and news).

Counter: a variable or user interface that counts occurrences or repetitions of some phenomena or event.

@tonymorris
tonymorris / IO.scala
Created November 5, 2013 23:57
Pure-functional IO in Scala
sealed trait IOOperation[A] {
def map[B](f: A => B): IOOperation[B] =
this match {
case PutChar(c, a) =>
PutChar(c, f(a))
case GetChar(g) =>
GetChar(f compose g)
}
}
case class PutChar[A](c: Char, a: A) extends IOOperation[A]
@plentz
plentz / nginx.conf
Last active April 19, 2025 04:46
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
[[[[[[[[[RACAbleWithStart(client, networkReachabilityStatus)
filter:^BOOL(NSNumber* statusNumber) {
AFNetworkReachabilityStatus status = statusNumber.intValue;
BOOL autoLoadOn3G = [[NSUserDefaults standardUserDefaults] boolForKey:KEY_AUTOLOAD_3G];
return (status == AFNetworkReachabilityStatusReachableViaWiFi
|| (autoLoadOn3G && status == AFNetworkReachabilityStatusReachableViaWWAN));
}]
take:1]
flattenMap: ^(id value){