Skip to content

Instantly share code, notes, and snippets.

View kovyrin's full-sized avatar

Oleksiy Kovyrin kovyrin

View GitHub Profile
#include <stdio.h>
#include <sys/select.h>
#include <fcntl.h>
#include <stdlib.h>
int main(int argc, char ** argv) {
char * dev_short = (argc > 1) ? argv[1] : "sda1";
char dev[512];
snprintf(dev, sizeof(dev), "/sys/block/%s/size", dev_short);
#!/bin/sh
# Set up an ssh tunnel to our proxy server + socks5 proxy endpoint at 127.0.0.1:1080
ssh -D 1080 -N -c blowfish -f proxy.local
#
# Cookbook Name:: yumrepo
# Definition:: yumrepo
#
# Copyright 2010, Tippr Inc.
#
# 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
#
@kpumuk
kpumuk / mysql_adapter_extensions.rb
Created April 15, 2011 17:24
Trace SQL queries in Rails 2
module OpsApi
# Helper methods for `ActiveRecord::ConnectionAdapters::MysqlAdapter` to enable SQL queries
# tracing functionality. There are two goals:
#
# * Add source line into the query itself so it would be possible to understand where
# the query was issues from:
#
# SELECT * FROM `admins` WHERE
# ((`admins`.`user_id` = 1)) LIMIT 1
# /*OOPS:app/models/user.rb:72:in `admin?'*/
@julik
julik / unfuck_osx_readline_for_ruby.txt
Created August 24, 2011 13:10
Decent Readline support for irb/pry on Leopard and above for decent UTF8 input, with RVM
Ensure that your ~/.inputrc contains this
set convert-meta off
set input-meta on
set output-meta on
Install the REAL GNU readline from source
$ curl ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz | tar xfz - && cd readline-6.2 && ./configure --enable-multibyte && make && sudo make install
@Flamefork
Flamefork / ffmpeg.rb
Created December 27, 2011 22:21
ffmpeg & carrierwave
module CarrierWave
module FFMPEG
extend ActiveSupport::Concern
module ClassMethods
def faststart
process :faststart => true
end
def transcode options
@kovyrin
kovyrin / ruby-1.8.7-hash-randomize.patch
Created December 29, 2011 18:51
Ruby EE 2011.03 Hash Collision Fix
From 4f69a748ab820c6a8bd204f94d13d970847f575c Mon Sep 17 00:00:00 2001
From: RPM Builder <[email protected]>
Date: Thu, 29 Dec 2011 19:48:52 +0000
Subject: [PATCH] Backport randomized hash patch from upstream
---
source/inits.c | 4 ++
source/random.c | 74 ++++++++++++++++++++++++++++++---------
source/st.c | 14 +++++++-
source/string.c | 7 +++-
@rednaxelafx
rednaxelafx / DirectMemorySize.java
Created January 11, 2012 07:18
An Serviceability-Agent based tool to see stats of NIO direct memory, as an alternative on JDK6 without JMX support for direct memory monitoring. Only works on JDK6; to work on JDK7 will need some tweaking because static variables are moved to Java mirror
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
import sun.jvm.hotspot.utilities.*;
public class DirectMemorySize extends Tool {
@RISCfuture
RISCfuture / rails_template.rb
Last active September 30, 2015 20:27
Tim's Awesome Rails Template
# encoding: utf-8
require 'open3'
def rvm_env(cmd)
Open3.popen3 "bash -c 'source ~/.rvm/scripts/rvm && #{cmd}'" do |stdin, stdout, stderr, thread|
thread.join
end
end
@leinaddm
leinaddm / dell_soap_check.py
Created February 23, 2012 14:18
dell warranty check
#!/usr/bin/python
# Daniel De Marco - [email protected] - 2012-02-23
# suds from https://fedorahosted.org/suds/
import suds
import sys
def get_warr(svctag):