Skip to content

Instantly share code, notes, and snippets.

View shtirlic's full-sized avatar
📡

Serg Podtynnyi shtirlic

📡
View GitHub Profile
@shtirlic
shtirlic / tsocks.rb
Created February 26, 2013 11:39
tsocks formula for homebrew
require 'formula'
class Tsocks < Formula
# The original is http://tsocks.sourceforge.net/
# This GitHub repo is a maintained fork with OSX support
homepage 'http://github.com/pc/tsocks'
head 'https://github.com/pc/tsocks.git'
depends_on 'autoconf' => :build if MacOS.xcode_version.to_f >= 4.3
@shtirlic
shtirlic / prfunct.plugin.zsh
Last active December 15, 2016 15:27
Simple oh-my-zsh plugin for projects management
# Go to the project dir
prcd() {
project=$*
cd $PROJECTS_HOME/$project
}
# Create new project and cd in the project path and open ST
prnew() {
mkdir "$PROJECTS_HOME/$*" && cd "$PROJECTS_HOME/$*" && git init
}
@shtirlic
shtirlic / main.c
Created February 2, 2013 21:10
run mruby code
#include <stdlib.h>
#include <stdio.h>
/* Include the mruby headers */
#include <mruby.h>
#include <mruby/proc.h>
#include <mruby/data.h>
#include <mruby/compile.h>
int main(int argc, const char * argv[])
@shtirlic
shtirlic / mono.rb
Last active May 21, 2017 16:55
Latest mono formula for homebrew
# http://www.mono-project.com/Compiling_Mono_on_OSX
require 'formula'
class Mono < Formula
#url 'http://download.mono-project.com/sources/mono/mono-3.0.6.tar.bz2'
#sha1 'e2187f80366fcd65c55a1ab946f8d3b39e81be77'
url 'http://download.mono-project.com/sources/mono/mono-2.10.9.tar.bz2'
sha1 '1a6e8c5a0c3d88d87982259aa04402e028a283de'
@shtirlic
shtirlic / Toolchain-OSX-androideabi.cmake
Created November 29, 2012 16:13
mruby Toolchain-OSX-androideabi
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
include(android.toolchain)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
@shtirlic
shtirlic / socket.rb
Created November 23, 2012 19:29
working http server sample
require 'socket'
require "http/parser"
READ_CHUNK = 1024 * 4
socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
addr = Socket.pack_sockaddr_in(9799, '127.0.0.1')
socket.bind(addr)
socket.listen(Socket::SOMAXCONN)
socket.setsockopt(:SOCKET, :REUSEADDR, true)
@shtirlic
shtirlic / bool_exp.rb
Created November 16, 2012 20:16
True/False block for bool (inspired by @rkh)
def true.if_true; yield end;
def false.if_true; end;
def true.if_false; end;
def false.if_false; yield end;
a = true
[]
HELLO
hello
[{:upcase!=>"hello"}, {:downcase!=>"HELLO"}]
[Finished in 0.1s]
@shtirlic
shtirlic / battery.sh
Created November 3, 2012 13:42
Battery status cmd for mac os x
#!/bin/sh
isFullyCharged=`ioreg -n AppleSmartBattery | grep FullyCharged | awk '{ print $5 }'`
timeLeft=`ioreg -n AppleSmartBattery | grep TimeRemaining | awk '{ print $5 }'`
isCharging=`ioreg -n AppleSmartBattery | grep IsCharging | awk '{ print $5 }'`
if [ $isFullyCharged = "Yes" ] ; then
output="Full Charge"
else
output="$timeLeft mins"
if [ $isCharging = "Yes" ] ; then
@shtirlic
shtirlic / 1
Created October 31, 2012 22:16
Dynamic condition
class Item < ActiveRecord::Base
has_many :places, conditions: Proc.new { "filter_status = #{@filter_status}"}
attr_accessor :filter_status
end