Skip to content

Instantly share code, notes, and snippets.

@ayosec
ayosec / paste_img.py
Created September 15, 2012 16:19
Create images from clipboard
#!/usr/bin/python
#
# Usage: python paste_img.py dest_file.png
#
# This program readd the image stored in the clipboard, and dumps it into a file
import gtk, pygtk
pygtk.require('2.0')
import sys
@ayosec
ayosec / en.yml
Created October 18, 2012 05:47
POC: Type locales in Scala
package: myapp.foo.locales
en:
mailbox:
header:
title: "Your mailbox"
subtitle: "Read and send messages"
welcome: "Welcome %{user}!"
actions:
@ayosec
ayosec / OpenSSL and RSA.md
Created December 17, 2012 21:43
Encrypt/descrypt with OpenSSL and RSA

OpenSSL and RSA

You can encrpt files using a private/public keys.

First, create the keys:

openssl req -x509 -nodes -days 100000 -newkey rsa:2048 \
  -keyout private.pem -out public.pem -subj /
@ayosec
ayosec / README.md
Last active December 10, 2015 17:48
Basic client to get PivotalTracker stories, in a easy to read format.

List for PivotalTracker stories

Get the stories for your PitalTracker project.

Installation

  • Install httparty and term-ansicolor gems
  • Download the pt-list.rb file in this gist.
  • Set execution flag with chmod +x
  • Put it in some directory in your $PATH
@ayosec
ayosec / g.rb
Last active December 12, 2015 04:18
Gaussian-like distribution
def g(n, center, amplitude, total, density)
Math.sinh(density*((n.to_f - total / 2.0))/(total/2.0))/Math.sinh(density) * amplitude + center
end
N = 30
Density = 10
prev_value = nil
(0..N).each do |n|
value = g(n, 35, 10, N, Density)
print "%3d %.4f" % [n, value]
@ayosec
ayosec / server_launcher.rb
Created May 22, 2013 14:27
Script to launch (and restart when stopped servers)
require "etc"
# Script used to launch servers, and track their status
groups = {}
pid = nil
uid = nil
ARGV.each do |argument|

Inheritance is a key concept in most object-oriented languages, but applying it skillfully can be challenging in practice. Back in 1989, M. Sakkinen wrote a paper called Disciplined inheritance that addresses these problems and offers some useful criteria for working around them. Despite being more than two decades old, this paper is extremely relevant to the modern Ruby programmer.

Sakkinen's central point seems to be that most traditional uses of inheritance lead to poor encapsulation, bloated object contracts, and accidental namespace collisions. He provides two patterns for disciplined inheritance and suggests that by normalizing the way that we model things, we can apply these two patterns to a very wide range of scenarios. He goes on to show that code that conforms to these design rules can easily be modeled as ordinary object composition, exposing a solid alternative to tradi

@rwjblue
rwjblue / readme.md
Last active May 13, 2016 18:10
Guide to using drip with JRuby

#Overview drip is an awesome command line tool that can be used to dramatically lower perceived JVM startup time. It does this by preloading an entirely new JVM process\instance and allowing you to simply use the preloaded environment. This has extraordinary results with jruby.

We reduced time to run rake environment from 13 seconds to a mere 3.5 seconds. This is actually at or near MRI 1.9.3p327 (with falcon patch) speeds!

Adding a few addition jruby options will reduce startup time even further (down to 1.69 seconds).

#Install Drip Install drip if you haven't already (see https://github.com/flatland/drip)

Disable "heads up" notifications in Android 7
$ adb shell settings set global heads_up_notifications_enabled 0