Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl -w # camel code
use strict;
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..3)
{<DATA>;}my @camel1hump;my$camel;
my$Camel ;while( <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
@ivan1911
ivan1911 / EventManager
Created July 12, 2015 07:40
PHP EventManager template class
<?php
class EventManager
{
public $listeners = [];
public function register($eventName, $listener)
{
$this->listeners[$eventName][] = $listener;
}
@ivan1911
ivan1911 / skype_get_name.py
Created December 17, 2013 07:12
Get chat name using blob. U can get blob using /get uri in skype client
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Skype4Py
# Create an instance of the Skype class.
skype = Skype4Py.Skype()
# Connect the Skype object to the Skype client.
skype.Attach()
upstream phpfcgi {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name lostepisode.ru www.lostepisode.ru;
root /www/lostepisode.ru/web;
error_log /www/logs/lostepisode.ru/error.log;
access_log /www/logs/lostepisode.ru/access.log;
@ivan1911
ivan1911 / Twilight.tmTheme
Created September 6, 2013 06:52
Twilight theme (include my personal colors)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Michael Sheets</string>
<key>name</key>
<string>Twilight</string>
<key>settings</key>
<array>
@ivan1911
ivan1911 / bh_core.sublime-settings
Created September 6, 2013 06:52
ST3 BracketHighlighter settings file http://goo.gl/weSryb
{
//Debug logging
"debug_enable": false,
// When only either the left or right bracket can be found
// this defines if the unmatched bracket should be shown.
"show_unmatched" : true,
// High visibilty style and color for high visibility mode
// (solid|outline|underline|thin_underline|squiggly|stippled)
@ivan1911
ivan1911 / Default (Windows).sublime-keymap
Last active December 20, 2015 16:29
Sublime Windows Keybindings
[
{ "keys": ["ctrl+e"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["ctrl+shift+b"], "command": "expand_selection", "args": {"to": "brackets"} },
{ "keys": ["ctrl+b"], "command": "move_to", "args": {"to": "brackets"} },
{ "keys": ["ctrl+k"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
{ "keys": ["ctrl+r"], "command": "show_panel", "args": {"panel": "replace"} },
{ "keys": ["ctrl+shift+r"], "command": "replace_next" },
{ "keys": ["ctrl+s"], "command": "save" },
{ "keys": ["ctrl+shift+s"], "command": "prompt_save_as" },
{ "keys": ["ctrl+u"], "command": "upper_case" },
@ivan1911
ivan1911 / random_password.php
Created July 12, 2013 10:53
Generate random password
function random_password( $length = 8 ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr( str_shuffle( $chars ), 0, $length );
return $password;
}
@ivan1911
ivan1911 / dijkstra.py
Last active December 5, 2022 14:36
My own realisation of Dijkstra's algorithm on Python.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Алгоритм Дейкстры
# Находит кратчайшее расстояние от одной из вершин графа до всех остальных.
# Алгоритм работает только для графов без рёбер отрицательного веса.
# Матрица задается как список словарей смежности вершин
# Описание алгоритма http://goo.gl/KsqC
@ivan1911
ivan1911 / UserDomains.sql
Created July 5, 2013 11:43
User Email Domains popularity MySQL
SELECT SUBSTRING_INDEX(Email, '@', -1) as Domain, count(*) as Total
FROM Users
GROUP BY Domain
ORDER BY Total DESC
LIMIT 15;