Skip to content

Instantly share code, notes, and snippets.

View user454322's full-sized avatar
💭
I may be slow to respond.

Javier user454322

💭
I may be slow to respond.
View GitHub Profile
@user454322
user454322 / threads.rb
Last active August 29, 2015 13:55
Simple Ruby program to test threads
def sub1
i=0
while
i = rand(10) + i
#puts "In thread"
end
end
th = Thread.new{sub1}
th1 = Thread.new{sub1}
@user454322
user454322 / svndiff_helper
Last active August 29, 2015 14:01
This is a simple wrapper intended for use with the --diff-cmd argument of 'svn diff'
#!/usr/bin/python
# Forked from:
# https://github.com/c4rlo/Subversion-scripts/blob/master/svndiff_helper
#
# The easiest way to use this script is by setting
# diff-cmd = svndiff_helper
# in section [helpers] in your ~/.subversion/config.
import sys, re, subprocess, os, os.path
@user454322
user454322 / mode_stat.c
Created June 21, 2014 01:32
umask chmod open
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#define RW_UGO (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH| S_IWOTH)
int
main(int argc, char **argv, char **env) {
@user454322
user454322 / openssl_android_v.sh
Created September 12, 2014 11:23
Find out which OpenSSL version is used in each version of Android
#!/bin/sh
#git clone https://android.googlesource.com/platform/external/openssl
for ANDROID_TAG in $(git ls-remote --tags| colrm 1 48| grep -v "\^{}")
do
git checkout "$ANDROID_TAG"
OPENSSL_V="$(cat openssl.version)"
echo "[$OPENSSL_V] - [$ANDROID_TAG]" >> openssl.versions
done
netcat
user@server$ cat /tmp/oom-heapdump | nc -l 9741
me@local$ nc server.com 9741 > oom-heapdump
@user454322
user454322 / .vimrc
Created October 12, 2012 19:50
Vim rc November 2012
set sw=4
set sts=4
set et
set autoindent
set smartindent
set incsearch
set ignorecase
set smartcase
set backspace=indent,eol,start
set vb
@user454322
user454322 / ip_js.html
Created October 20, 2012 21:29
getting IP info with JavaScript
<html>
<head>
<script type="text/javascript">
function getLocalIP(){
var yip2=java.net.InetAddress.getLocalHost();
var yip=yip2.getHostAddress();
document.getElementById("ip_addr").innerHTML=yip;
}
var ipx ="ERROR"
@user454322
user454322 / monitor_replication.rb
Created November 23, 2015 08:04
CouchDB replication
#!/usr/bin/env ruby
#Start CouchDB replication with
#curl -X POST -d '{"source":"https://user:passwd@src_ip:6984/source_db", "target":"https://user:passwd@dst_ip:6984/dst_db", continuous:true}' -H 'Content-Type: application/json' https://host:6984/_replicator
# This script checks a list of databases that should be replicating and their last replication time.
# If the replication hasn't been updated in an hour, an email is sent to 'email@example.com'
# with the subject 'CouchDB replication problem'.
bad_names=["threadList","handleSuspend","handleDisturb","handleDisturbAction","handleFollowParent","handleFollowChild","handleDisturbSession","handleResume","handleStatus","setBreakPoint","deleteBreakPoint","handleBreak","handleBreak","handleClear","setCommonBreakPoint","handleCommonBreak","handleContinue","handlePrint","handleExec","handleUp","handleDown","handleUp","handleStep","handleNext","handleReturn","handleWhere"]
bad_names.each{|name|
good = String.new(name)
name.split("").each{|charr|
if(charr =~ /[A-Z]/)
good.gsub!(charr,"_"+charr.downcase)
end
}
@user454322
user454322 / gist:5610855
Created May 20, 2013 07:29
Monitor the number of PostgreSQL connections
#! /bin/sh
# Configurarion
DBHOST="127.0.0.1"
DBPORT="5432"
DBNAME="as_3_7_5"
PGUSER="postgres"
PGPASSWORD="a"
PGSQL_CMD="/usr/bin/psql"
AS_SERVER="127.0.0.1"