Skip to content

Instantly share code, notes, and snippets.

View sardaukar's full-sized avatar
:shipit:
Always be shipping

Bruno Antunes sardaukar

:shipit:
Always be shipping
View GitHub Profile
@joshaven
joshaven / vash.rb
Created September 10, 2009 21:19
Volatile Ruby Hash > Vash
#############################################################################
# Class: Vash (Ruby Volatile Hash)
# Hash that returns values only for a short time. This is useful as a cache
# where I/O is involved. The primary goal of this object is to reduce I/O
# access and due to the nature of I/O being slower then memory, you should also
# see a gain in quicker response times.
#
# For example, if Person.first found the first person from the database & cache
# was an instance of Vash then the following would only contact the database for
# the first iteration:
@bowsersenior
bowsersenior / stooge_loader.rb
Created May 18, 2011 23:18
A demo of YAML anchors, references and nested values
require 'rubygems'
require 'yaml'
# A demonstration of YAML anchors, references and handling of nested values
# For more info, see:
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
stooges = YAML::load( File.read('stooges.yml') )
# => {
# "default" => {
@moomerman
moomerman / two_factor_ssh.rb
Created September 23, 2011 11:32
Two Factor SSH Authentication
#!/usr/bin/env ruby
require 'rubygems'
require 'rotp'
require 'time'
user = ARGV[0]
secret = ARGV[1]
abort unless user and secret
trap("INT") do
@mguymon
mguymon / knockr.rb
Created December 8, 2011 17:58
Simply ruby port knocker
#!/usr/bin/env ruby
require 'socket'
require 'timeout'
def knock?(ip, port)
begin
Timeout::timeout(2) do
begin
s = TCPSocket.new(ip, port)
@trcarden
trcarden / gist:3295935
Created August 8, 2012 15:28
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@1wErt3r
1wErt3r / SMBDIS.ASM
Created November 9, 2012 22:27
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger (doppelheathen@gmail.com)
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no
@L422Y
L422Y / osx_automount_nfs.md
Last active May 10, 2024 09:06
Automounting NFS share in OS X into /Volumes

I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:

/etc/auto_master (see last line):

#
# Automounter master map
#

+auto_master # Use directory service

@deepakkumarnd
deepakkumarnd / server_setup.sh
Last active April 3, 2020 15:14
Server setup script
# This script has to be run as a root user
echo "* Updating system"
apt-get update
apt-get -y upgrade
echo "* Installing packages"
apt-get -y install build-essential libmagickcore-dev imagemagick libmagickwand-dev libxml2-dev libxslt1-dev git-core nginx redis-server curl nodejs htop
id -u deploy &> /dev/null
if [ $? -ne 0 ]
@mks-m
mks-m / tiny_redis.rb
Last active April 7, 2021 16:47
tiny_redis_client.rb
# Copyright 2017 Maksym Melnychok
# MIT License - https://opensource.org/licenses/MIT
#
# inspired by https://github.com/ptrofimov/tinyredisclient
require 'socket'
class TinyRedis
RN = "\r\n"
@biomancer
biomancer / playlist_builder.rb
Created September 18, 2014 14:48
Generating i-frame and byterange m3u8 playlist from .ts video file for usage in HLS
module PlaylistBuilder
SEG_DURATION, PKT_SIZE, PKT_POS, PKT_TIME = 0,1,2,3
def self.extract_iframes_data(video_filepath)
raise "#{video_filepath} does not exists!" unless File.exists?(video_filepath)
iframes_data = []
cmd = "ffprobe -show_frames -select_streams v -of compact -show_entries packet=pts_time,codec_type,pos:frame=pict_type,pkt_pts_time,pkt_size,pkt_pos -i #{video_filepath.shellescape}"
frames_and_packets = nil
r = Benchmark.measure('') do
frames_and_packets = `#{cmd}`.split("\n")