Skip to content

Instantly share code, notes, and snippets.

View shtirlic's full-sized avatar
📡

Serg Podtynnyi shtirlic

📡
View GitHub Profile
# http://www.mono-project.com/Compiling_Mono_on_OSX
require 'formula'
class MonoBasic < Formula
url 'http://download.mono-project.com/sources/mono-basic/mono-basic-2.10.tar.bz2'
homepage 'http://www.mono-project.com/'
@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 / 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 / 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

Keybase proof

I hereby claim:

  • I am shtirlic on github.
  • I am shtirlic (https://keybase.io/shtirlic) on keybase.
  • I have a public key whose fingerprint is 8E9F DE81 F95E 7CE2 C672 6B79 9D70 05BA E592 87C2

To claim this, I am signing this object: