Skip to content

Instantly share code, notes, and snippets.

View denvazh's full-sized avatar

Denis Vazhenin denvazh

  • Tokyo
View GitHub Profile
@le-doude
le-doude / ManacherAlgorithm.java
Created June 19, 2014 06:49
Solving the problem: Find the longest palindrome in a random character array. Can also be used to find all possible palindromes in the same sequence. http://en.wikipedia.org/wiki/Longest_palindromic_substring
import java.util.Arrays;
/**
* Created by le-doude on 14/06/19.
* <p/>
* Did you know it is possible to find the longest palindrom in a char sequence in O(N) time.
* Here is the solution: Manacher's algorithm.
* http://en.wikipedia.org/wiki/Longest_palindromic_substring
*/
public class ManacherAlgorithm {
@gosuri
gosuri / dfs.rb
Last active December 14, 2015 17:59
Recursive depth-first search (DFS) for traversing a graph in ruby.
# Depth-first search (DFS) is an algorithm for traversing or
# searching a tree, tree structure, or graph. One starts at
# the root (selecting some node as the root in the graph case)
# and explores as far as possible along each branch before backtracking.
#
# A graph can be represented by its adjacency matrix G,
# where G[i][j] == 1 if there is an edge between
# vertices i and j and 0 otherwise.
#
# Below Graph in diagram http://i.imgur.com/sV1UzUn.png
#!/usr/bin/env python
from pymarkov import markov
from random import choice
import doctest
import argparse
class Generate:
""" A song generator. Generate takes input (musician, album) and returns
a version of that musician's songs.
@hylom
hylom / mecab.spec
Created May 9, 2013 10:53
MeCab's spec file for rpmbuild
%define name mecab
%define version 0.996
%define release el6.4
Summary: Yet Another Part-of-Speech and Morphological
Name: %{name}
Version: %{version}
Release: %{release}
Source0: https://mecab.googlecode.com/files/mecab-%{version}.tar.gz
License: GPL/LGPL/BSD
@thiago-vieira
thiago-vieira / open.py
Last active April 20, 2017 14:07
natural open struct in python
class Class:
pass
x = Class()
x.something = 42
print(x.something) # 42
@n-miyo
n-miyo / gitlab
Last active May 28, 2017 07:17 — forked from denvazh/gitlab
#!/bin/sh
#
# Written by Denis Vazhenin <denis.vazhenin@me.com>
#
# This script was ported from Debian/Ubuntu version of start script for Gitlab:
# https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/init.d/gitlab
#
# PROVIDE: gitlab
# REQUIRE: NETWORKING SERVERS DAEMON LOGIN
# KEYWORD: shutdown
#!/bin/sh
#
# Downloads and installs the startssl CA certs into the global Java keystore
# on Alpine Linux.
#
# Check if JAVA_HOME is set
[ "$JAVA_HOME" = "" ] && echo "ERROR: JAVA_HOME must be set" && exit 1
# Check if cacerts file is present
@czj
czj / gist:1251031
Created September 29, 2011 15:43
.irbrc that runs Pry instead of IRB
# This script comes from Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
@beyondeye
beyondeye / firebase_coroutine_integration.kt
Created May 27, 2017 20:32
integration of firebase wth kotlin coroutines
/**
* allow to define callback wrappers that are protected from accidental multiple calls to resume/resumeWithException
* Created by daely on 3/30/2017.
*/
class WrappedContinuation<T>(val c: Continuation<T>) : Continuation<T> {
var isResolved = false
override val context: CoroutineContext
get() = c.context
override fun resume(value: T) {
@sauloperez
sauloperez / signal_catching.rb
Last active November 11, 2020 11:25
How to catch SIGINT and SIGTERM signals in Ruby
# Signal catching
def shut_down
puts "\nShutting down gracefully..."
sleep 1
end
puts "I have PID #{Process.pid}"
# Trap ^C
Signal.trap("INT") {