Skip to content

Instantly share code, notes, and snippets.

View gazay's full-sized avatar
🌐

Alex Gaziev gazay

🌐
View GitHub Profile
@gazay
gazay / build
Created January 31, 2015 06:42
Linker error with android-haskell-activity
androidbuilder@aa3718480a89:~/android-haskell-activity$ arm-linux-androideabi-cabal build --verbose=3
Using internal setup method with build-type Simple and args:
["build","--verbose=3","--builddir=dist","--jobs=8","--with-gcc=/home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-gcc","--with-ghc=/home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/bin/arm-unknown-linux-androideabi-ghc","--with-ghc-pkg=/home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/bin/arm-unknown-linux-androideabi-ghc-pkg","--with-hsc2hs=/home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/bin/arm-unknown-linux-androideabi-hsc2hs","--with-ld=/home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-ld","--with-strip=/home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-strip","--hsc2hs-option=--cross-compile"]
("/home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-gcc",["
@gazay
gazay / gist:d9a71cc79ea5d56f35cc
Created January 30, 2015 18:26
Android builder failure
androidbuilder@cf12994d95a0:~/foreign-jni$ arm-linux-androideabi-cabal install
Resolving dependencies...
Downloading text-1.2.0.4...
Downloading transformers-0.4.2.0...
Configuring text-1.2.0.4...
Configuring transformers-0.4.2.0...
Failed to install text-1.2.0.4
Build log ( /home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/.cabal/logs/text-1.2.0.4.log ):
[1 of 1] Compiling Main ( /tmp/text-1.2.0.4-59/text-1.2.0.4/dist/setup/setup.hs, /tmp/text-1.2.0.4-59/text-1.2.0.4/dist/setup/Main.o )
Linking /tmp/text-1.2.0.4-59/text-1.2.0.4/dist/setup/setup ...

GIML

Gazay's incomplete Minimalistic Language.

By Alexey Gaziev.

Objectives

Smallest and incomplete language for big but simple config files. It should be so simple that you can write fast parser for it in few LOC and without heavy dependencies.

import System.Random (newStdGen, randomR)
import Gimlh
import Data.List.Split (splitOn)
import Data.List (intercalate)
import Control.Monad.State
main = putStrLn $ runFaker $ do
n <- name
return $ unwords ["Hello", "my", "name", "is", n]
@gazay
gazay / raw
Created December 16, 2013 15:43
"require 'spec_helper'\n\ndescribe 't34' do\n let(:target) {\n\"class X\n def test_method(arg1)\n end\nend # X\"\n }\n\n let(:target2) {\n\"class X\n def test_method(xxx, arg2)\n end\nend # X\"\n }\n\n let(:source) {\n\"class X\n def test_method(arg1, arg2)\n end\nend\"\n }\n\n let(:rewriter) {\n T34::Rewriter.new source\n }\n\n it 'finds methods' do\n expect(rewriter.methods(:test_method)).to be_kind_of Array\n end\n\n it 'finds method nodes' do\n expect(rewriter.methods(:test_method).map(&:class).compact).to eq [T34::Rewriter::API::MethodNode]\n end\n\n it 'manipulates methods' do\n res = rewriter.methods(:test_method) do |method_node|\n method_node.args = method_node.args[0...-1]\n end\n expect(res[0].args.size).to eq 1\n end\n\n it 'manipulates arguments by name' do\n res = rewriter.methods(:test_method) do |method_node|\n method_node.args = method_node.args.select { |it| it.name != 'arg2' }\n end\n expect(res[0].args.size).to eq 1\n expect(rewr
@gazay
gazay / helper.rb
Created October 10, 2012 16:59
Autocreating heroku app
require 'fileutils'
class Helper
attr_accessor :dir, :temp_dir
attr_reader :template_path, :original_dir
def initialize(dir = nil)
@template_path = File.expand_path('../../app_template', __FILE__)
@original_dir = FileUtils.pwd
@gazay
gazay / client
Created October 7, 2012 04:19
Heroku proxy
#!/usr/bin/env ruby
client_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'proxy'))
$LOAD_PATH.unshift(client_dir) unless $LOAD_PATH.include?(client_dir)
require 'client'
# Get parameters and start the server
if ARGV.size == 2
port, proxy = ARGV
port = port.to_i
@gazay
gazay / proxy.rb
Created October 5, 2012 05:47
Simple proxy server
# Based on https://gist.github.com/74107 by # Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com>
#
# Rewrited by gazay
require 'socket'
require 'uri'
class Proxy
attr_accessor :socket
@gazay
gazay / gist:2629683
Created May 7, 2012 18:57
Realisations of Range#=== in ruby18 and ruby19
# implementation of Range#=== in 1.8.7 - it was the same method as Range#include?:
<<-EOS
static VALUE
range_include(range, val)
VALUE range, val;
{
VALUE beg, end;
beg = rb_ivar_get(range, id_beg);
end = rb_ivar_get(range, id_end);
#!/usr/bin/env ruby
require 'epath'
bom = "\xEF\xBB\xBF".force_encoding('binary')
Path.glob('**/*.rb') do |file|
next if file.binread(3) == bom
previous = file.binread
file.write bom + previous
end