Skip to content

Instantly share code, notes, and snippets.

View dmalikov's full-sized avatar
🥞
!

Dmitry Malikov dmalikov

🥞
!
View GitHub Profile
@dmalikov
dmalikov / !.md
Last active December 15, 2015 02:59
!

How to make merge commit with same parent commits

git cat-file commit master | awk '/^parent.*/{print $0}; //{print $0}' | git hash-object --stdin -w -t commit | xargs git checkout -B master

Here it is:

$> git show --stat

commit 52eb56f6d5816f9e43015878e60a41cbbfb3e702

@dmalikov
dmalikov / map.java
Created March 17, 2013 09:04
Clean and short
// es = map exists tasks
List<Boolean> es = Lists.transform(tasks, new Function<File, Boolean>() {
@Override
public Boolean apply(File file) {
return file.exists();
}
});
@dmalikov
dmalikov / ssr.rb
Created March 8, 2013 22:30
RUBY FOONKTSHIANOL OPPLEEKATION SSYSTEM STACK ERROR
def get_hostid_by_itemid(itemid)
message = {
'method' => 'host.get',
'params' => {
'itemids' => [itemid.to_s]
}
}
return send_request(message).first["hostid"]
end
#!/usr/bin/env ruby
require 'gnuplot'
require 'ostruct'
def read file
times = []
File.open(file).each do |line|
_,a,_ = line.split(' ')
times << Float(a)/1000000
@dmalikov
dmalikov / install.sh
Created March 3, 2013 19:03
Small ghc-7.6.2 bootstrap
#!/bin/bash
set -e
##########################
# INSTALL GHC
##########################
GHC="ghc.tar.bz2"
# install depends
sudo apt-get install --assume-yes libgmp3c2
@dmalikov
dmalikov / hw3.sml
Created February 11, 2013 21:51
Programming Languages, week 3
exception NoAnswer
val only_capitals = List.filter (fn s => Char.isUpper (String.sub (s,0)))
val longest_string1 = foldl (fn (s,m) => if String.size s > String.size m then s else m) ""
val longest_string2 = foldl (fn (s,m) => if String.size s >= String.size m then s else m) ""
fun longest_string_helper p = foldl (fn (s,m) => if (p (String.size s) (String.size m)) then s else m) ""
@dmalikov
dmalikov / smackage-bootstrap.rb
Created February 4, 2013 21:43
Primitive routine to install smackage with configured mlton and smlnj
#!/usr/bin/env ruby
require 'rubygems'
require 'git'
require 'fileutils'
# Directory that suppose to be in $PATH
bin_dir = File.join(Dir.home, 'bin')
smackage_dir = File.join(Dir.home, 'projects/smackage')
@dmalikov
dmalikov / week02.sml
Last active December 12, 2015 00:58
Programming Languages Homework 2
(* routines *)
fun map f (x::xs) = f x :: map f xs
| map _ [] = []
fun concat (x::xs) = x @ concat xs
| concat [] = []
fun mapPartial _ [] = []
| mapPartial f (x::xs) = case f x
of SOME v => v :: (mapPartial f xs)
@dmalikov
dmalikov / BF.hs
Last active December 10, 2015 18:09
ADAA2 Week 4 (Bellman-Ford + Dijkstra)
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UnicodeSyntax #-}
import Control.Applicative (many, (<$>), (<*))
import Control.Lens
import Data.Attoparsec.Text.Lazy
import qualified Data.HashMap.Strict as M
import Data.List (nub, sort)
import Data.Text.Lazy.IO as T
import qualified Algo.BellmanFord as BF
@dmalikov
dmalikov / Capfile.rb
Created December 7, 2012 22:46
deploy liblastfm haddocks to budueba.com
# Deploying haddocks
#
# cap deploy:haddocks
load 'deploy'
ssh_options[:forward_agent] = true
after "deploy:create_symlink", "deploy:cleanup"