Skip to content

Instantly share code, notes, and snippets.

@sanmai
sanmai / README.md
Last active June 29, 2017 12:13
root на Samsung Galaxy S - Android version 2.2 Froyo

Нужно включить отладку по USB:

Settings -> Applications -> Development -> USB debugging

Наш девайс должен быть виден.

$ adb devices
List of devices attached
100044ddd111	device
@sanmai
sanmai / warm-up-mysql.sh
Last active May 27, 2017 03:44
Warm up MySQL caches: `./warm-up-mysql.sh db-name`
#!/bin/bash
echo "SELECT
CONCAT('SELECT ',MIN(c.COLUMN_NAME),' FROM ',c.TABLE_NAME,' WHERE ',MIN(c.COLUMN_NAME),' IS NOT NULL;')
FROM
information_schema.COLUMNS AS c
LEFT JOIN (
SELECT DISTINCT
TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME
FROM
information_schema.KEY_COLUMN_USAGE
@sanmai
sanmai / README.md
Created May 27, 2017 02:51
standard deviation of an arbitrary numbers in bash with octave

Sample usage:

seq 1 1000 | ./stddev.sh

Sample output:

MEAN	68%	95%	97%
500.50    789.32   1078.14   1366.96
@sanmai
sanmai / main.go
Created July 11, 2016 07:57
Adds label to an image
package main
import (
"image"
"image/color"
"image/png"
"os"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
@sanmai
sanmai / main.go
Created July 4, 2016 06:15
Simple counting server
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
var count int
@sanmai
sanmai / startswith_benchmark.php
Last active June 7, 2016 07:32 — forked from mnpenner/startswith_benchmark.php
Various StartsWith implementations
<?php
/*
Run with all available processing power:
sudo nice -n -20 php startswith_benchmark.php | sort -h
Running with PHP 7.0.7-3 gives:
1.6±0.0014 msec - strncmp_startswith_shortcut
@sanmai
sanmai / Symfony.xml
Created May 17, 2016 03:04
Eclipse PHP code formatter profile export
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles>
<profile name="Symfony">
<setting id="indentationChar" value=" "/>
<setting id="insert_space_after_opening_paren_in_declare" value="false"/>
<setting id="insert_space_before_closing_paren_in_declare" value="false"/>
<setting id="insert_space_before_opening_paren_in_declare" value="false"/>
<setting id="org.eclipse.php.core.formatter.insert_new_line_in_function_invoke" value="3"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_force_split" value="false"/>
<setting id="org.eclipse.php.formatter.core.formatter.alignment_for_arguments_in_allocation_expression_indent_policy" value="0"/>
@sanmai
sanmai / example.xml
Last active August 16, 2023 12:53
Генератор данных по товарам в формате YML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="2016-03-14 18:03">
<shop>
<name>Shop Name</name>
<company>Company Name</company>
<url>https://www.example.com/</url>
<currencies>
<currency id="RUR" rate="1"/>
<currency id="USD" rate="81.00"/>
@sanmai
sanmai / FLOW.md
Last active March 9, 2016 01:37
Patch Flow

First:

git format-patch -1 <sha1>

Then:

git am ../path/to/0001-file.patch

If patch did not apply cleanly:

@sanmai
sanmai / README.md
Last active April 12, 2016 01:58
Chained hook with Slack
mv --no-clobber .git/hooks/post-receive .git/hooks/post-receive-make
curl https://gist.githubusercontent.com/sanmai/ef0c2dd609ae72db03af/raw/chained-hook.sh > .git/hooks/post-receive
curl https://raw.githubusercontent.com/chriseldredge/git-slack-hook/master/git-slack-hook > .git/hooks/post-receive-slack
chmod +x .git/hooks/post-receive-* .git/hooks/post-receive

Configuration:

git config hooks.slack.webhook-url 'https://hooks.slack.com/services/...'

git config hooks.slack.repo-nice-name 'My Awesome Repository'