Skip to content

Instantly share code, notes, and snippets.

View alxfv's full-sized avatar

Alexander Fedorov alxfv

View GitHub Profile
/*
highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
server {
listen 80;
root /home/faost/www/test;
index index.html;
server_name test;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
<?php
function solve($n) {
if ($n > 0) {
echo solve($n - 1);
}
return $n;
}
solve(10);
@alxfv
alxfv / gist:b081080378f321fc9624
Created August 25, 2014 19:28
String reverse
<?php
for ($i = 0, $j = strlen($s) - 1; $i < strlen($s) / 2; $i++, $j--) {
$c = $s[$i];
$s[$i] = $s[$j];
$s[$j] = $c;
}
@alxfv
alxfv / gist:5bfae63a98d428192ee1
Last active August 29, 2015 14:05
trait example
<?php
trait CreatedTrait
{
/**
* @var DateTime
*/
protected $created;
/**
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package org.springframework.boot;
import java.lang.reflect.Constructor;
import java.nio.charset.Charset;
import java.security.AccessControlException;
@alxfv
alxfv / gist:0d8e7af175b7627fd526
Created June 15, 2015 20:22
avconv streaming to twitch
#! /bin/bash
# streaming on Ubuntu via ffmpeg.
# see http://ubuntuguide.org/wiki/Screencasts for full documentation
# see http://www.thegameengine.org/miscellaneous/streaming-twitch-tv-ubuntu/
# for instructions on how to use this gist
if [ ! -f ~/.twitch_key ]; then
echo "Error: Could not find file: ~/.twitch_key"
echo "Please create this file and copy past your stream key into it. Open this script for more details."
@alxfv
alxfv / ice_cube.ru.yml
Created December 25, 2015 08:20
Russian locale for ice_cube
ru:
ice_cube:
pieces_connector: ' / '
not: 'not %{target}'
not_on: 'not on %{target}'
date:
formats:
default: '%B %-d, %Y'
month_names:
-
@alxfv
alxfv / island_count.py
Created November 1, 2018 09:18
Island Count
def mark_island(grid, i, j):
if i >= 0 and j >= 0 and i < len(grid) and j < len(grid[i]) and grid[i][j] == 1:
grid[i][j] = 0
mark_island(grid, i, j+1)
mark_island(grid, i+1, j)
mark_island(grid, i, j-1)
mark_island(grid, i-1, j)
def get_number_of_islands(grid):
def oswalk(dirname):
if not os.path.isdir(dirname):
return
names = os.listdir(dirname)
filenames = []
dirnames = []
dirpaths = []