Skip to content

Instantly share code, notes, and snippets.

@shevron
shevron / LICENSE
Last active April 28, 2020 02:28
Send EC2 instance memory usage stats to CloudWatch using boto and IAM Roles
Copyright (c) 2015, Shahar Evron
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@dodyg
dodyg / gist:5823184
Last active March 29, 2024 03:59
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@p4ul
p4ul / upme.php
Last active December 11, 2015 22:18
This is a script that will update a Drupal site from git (github), clear the cache and send a deployment notice to New Relic. This can be called from github service hooks, CI server or browser. This is not recommended for a production environment unless you add some security / firewall rules etc.
<pre>
<?php
/**
Modify the capitalised variables with your info.
Call this from your github webservice hook / CI server.
If you are not using new relic you need to remove that cruft.
(the last 3 lines)
@p4ul
p4ul / getupdates.sh
Created January 22, 2013 23:20
check svn for updates and get formatted text for redmine broadcast
echo -e "Files to change:\n" \
&& svn st -u | grep -v ? \
&& echo -e "\nChange Log:\n" \
&& svn log -r BASE:HEAD | grep -v -e '^\-\|^$\|^r[0-9].'| sort -u | awk '{print "* " $0}'
@alexwybraniec
alexwybraniec / gist:2972487
Created June 22, 2012 12:32
Enabling Memcached graphing in Munin, Ubuntu 10.04 LTS, with munin-node already installed
sudo apt-get update
sudo apt-get install munin-plugins-extra
cd /etc/munin/plugins
sudo ln -snf /usr/share/munin/plugins/memcached_ memcached_bytes
sudo ln -snf /usr/share/munin/plugins/memcached_ memcached_counters
sudo ln -snf /usr/share/munin/plugins/memcached_ memcached_rates
sudo aptitude install libcache-memcached-perl
sudo /etc/init.d/munin-node restart
sudo tail -f /var/log/munin/munin-node.log
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@marfillaster
marfillaster / mimeapps.list
Created March 14, 2012 15:19
Sublime Text ubuntu xdebug url handler
#~/.local/share/applications/mimeapps.list
[Added Associations]
#...
x-scheme-handler/subl=subl-urlhandler.desktop
@krisleech
krisleech / newrelic_deployment.rb
Created February 1, 2012 10:08
Using NewRelic command to notify of deployment
# config(:branch) returns the branch being deployed.
# The newrelic command can accept an appname or appid, its undocumented, but it works.
# The appid can be found in the URL after logging in to NewRelic.
def notify_newrelic
sha1 = (`git rev-parse #{config(:branch)}`).chomp
description = (`git log #{config(:branch)} -1 --format="%s"`).chomp
command = "bundle exec newrelic deployments --appname=#{config(:application_id)} --revision=#{sha1} '#{description}'"
puts command
system command
@sgruhier
sgruhier / gist:1086231
Created July 16, 2011 10:14
override jquery UI widget method
// If you dont need to call original method
$.widget("ui.addresspicker", $.extend({}, $.ui.addresspicker.prototype, {
_updatePosition: function(){
// Do what you want to
}
}));
// If you need to call original method
var _updatePosition = $.ui.addresspicker.prototype._updatePosition;
$.widget("ui.addresspicker", $.extend({}, $.ui.addresspicker.prototype, {
@adamsilver
adamsilver / gist:701596
Created November 16, 2010 08:47
Qunit 'raises' assertion for JsTestDriver adapter
window.raises = function(fn, msg) {
try {
fn();
ok(false, msg ? msg : '')
} catch(e) {
ok(e.name === "AssertError" ? false : true, msg ? msg : '');
}
}