Skip to content

Instantly share code, notes, and snippets.

@keith
keith / simctl-commands.txt
Last active December 7, 2022 23:27
All the subcommands of `xcrun simctl` (including ones that aren't listed in `simctl help`) LC_SOURCE_VERSION 776.1 (Xcode 13.0 beta 5)
addmedia
addphoto
addvideo
appinfo
boot
bootstatus
clone
create
darwinup
delete

1. Store api keys in a xml file

Put xml file "api_keys.xml" in the directory "res/value/".

api_keys.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="THE_MOVIE_DB_API_TOKEN">XXXXX</string>
</resources>
@couchdeveloper
couchdeveloper / RXTimer.h
Last active July 29, 2019 06:55
A timer based on dispatch_source_create() Objective-C
//
// RXTimer.h
//
// Copyright 2013 Andreas Grosam
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active April 11, 2024 22:09
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@schlamar
schlamar / example.py
Last active February 13, 2022 18:15
mplog: Python advanced multiprocessing logging.
import logging
import multiprocessing
import time
import mplog
FORMAT = '%(asctime)s - %(processName)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
existing_logger = logging.getLogger('x')
@jdunck
jdunck / redis_leaky_bucket.py
Created November 17, 2012 08:16
leaky bucket queue - redis 2.6 + lua + python
#cribbed from http://vimeo.com/52569901 (Twilio carrier call origination moderation)
# The idea is that many fan-in queues can enqueue at any rate, but
# dequeue needs to happen in a rate-controlled manner without allowing
# any individual input queue to starve other queues.
# http://en.wikipedia.org/wiki/Leaky_bucket (second sense, "This version is referred to here as the leaky bucket as a queue.")
#
# requires:
# redis 2.6+
# redis-py>=2.7.0
# anyjson
@ashtom
ashtom / HockeySender.java
Created March 1, 2012 09:26
Custom ReportSender for HockeyApp and ACRA
package net.hockeyapp.android.demo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.acra.ACRA;
import org.acra.collector.CrashReportData;
import org.acra.ReportField;
import org.acra.sender.ReportSender;
@lpar
lpar / utf8truncate.java
Created June 17, 2011 18:21
Truncate a Java string so that its UTF-8 representation will not exceed the specified number of bytes
/**
* Truncate a Java string so that its UTF-8 representation will not
* exceed the specified number of bytes.
*
* For discussion of why you might want to do this, see
* http://lpar.ath0.com/2011/06/07/unicode-alchemy-with-db2/
*/
public static String utf8truncate(String input, int length) {
StringBuffer result = new StringBuffer(length);
int resultlen = 0;