Skip to content

Instantly share code, notes, and snippets.

@HakanL
HakanL / HighPrecisionTimer
Created January 30, 2013 00:34
C# code for a High Precision Timer (avg <1 ms for 25 ms interval). Fair use of CPU time. Uses NLog to log accuracy
using NLog;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Animatroller.Framework.Utility
{
public class HighPrecisionTimer : IDisposable
{
@Antarix
Antarix / LocalBroadcastExampleActivity.java
Created December 26, 2013 08:31
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@drmalex07
drmalex07 / drupal-entityfieldquery-example-1.php
Last active January 6, 2023 17:12
An example of an EntityFieldQuery in drupal 7. #drupal #php #drupal-entities
<pre><?php
////////////////////////////////////////////////////
// See more at https://drupal.org/node/1343708 //
////////////////////////////////////////////////////
//
// Filter entities based on several {entity,property,field}-based criteria
//
@TomTasche
TomTasche / nginx.conf
Last active January 27, 2023 21:22
config for nginx to proxy a specific path to an S3 bucket
# copied from default config
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@DallasO
DallasO / .bash_aliases
Last active April 14, 2023 23:38
My Bash aliases
## BASIC
alias x='exit'
alias c='clear'
alias ll='ls -lh' # List files/dirs, `-l` with more details, `-h` show filesize in human-readable format
alias grep='grep --color=auto' # COLORSS!
## Routine
alias update='sudo apt update && apt list --upgradeable' # Check for updates
alias upgrade='sudo apt upgrade --auto-remove' # Install those updates
alias autoremove='sudo apt autoremove && sudo apt autoclean' # Run every few months to clear apt cache
alias aptinstall='sudo apt install' # Install something from apt
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@lavalake
lavalake / gist:d83a5bc14284161433019475013996d1
Created October 14, 2017 01:54 — forked from tsohr/gist:5711945
Android activity manager "am" command help
adb shell am
usage: am [subcommand] [options]
usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]
[--R COUNT] [-S] [--opengl-trace] <INTENT>
am startservice <INTENT>
am force-stop <PACKAGE>
am kill <PACKAGE>
am kill-all
am broadcast <INTENT>
am instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]

Phoenix 1.4.x to 1.5.0 upgrade instructions

Phoenix 1.5 requires Elixir >= 1.7. Be sure your existing version is up to date by running elixir -v on the command line.

Install the new phx.new project generator

$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.5.0
@LeonardoCardoso
LeonardoCardoso / gitzip.sh
Last active October 9, 2023 22:38
Zip folder ignoring files listed on .gitignore
#...
function gitzip() {
git archive -o $@.zip HEAD
}
#... gitzip ZIPPED_FILE_NAME
@leandromoreira
leandromoreira / nginx.conf
Last active November 29, 2023 11:39
nginx.conf optmized for http/2 = HTTPS TLS (ssl)
# command to generate dhparams.pen
# openssl dhparam -out /etc/nginx/conf.d/dhparams.pem 2048
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
limit_req_status 444;
limit_conn_status 503;
proxy_cache_path /var/lib/nginx/proxy levels=1:2 keys_zone=backcache:8m max_size=50m;
proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";