Skip to content

Instantly share code, notes, and snippets.

View feedbee's full-sized avatar

Valera Leontyev feedbee

View GitHub Profile
@feedbee
feedbee / demo.js
Created January 6, 2019 20:27
Google AppScript, encode query string parameter in encoding other than UTF-8 (windows-1251 in current example)
function encode(string) {
var bytes = Utilities.newBlob("").setDataFromString(string, "windows-1251").getBytes();
var res = "";
for (var i = 0; i < bytes.length; i++) {
var n = bytes[i] & 0xFF;
var hexString = n.toString(16);
if (hexString.length % 2) {
hexString = '0' + hexString;
}
res += "%" + hexString.toUpperCase();
package main
import (
"fmt"
"net/http"
"strconv"
)
func main() {
ports := []int{8080, 8081}
@feedbee
feedbee / srv.go
Created March 31, 2018 12:07
Simple static files web server written in golang
package main
import "fmt"
import "net/http"
import "flag"
import "os"
import "path/filepath"
func main() {
// --help
@feedbee
feedbee / gist:a7d44ac35e02c13dcad7
Created July 13, 2015 11:34
Update git repository using BitBucket Webhook
<?php
/**
* BitBucket Webhook:
* Update git repository on push to given branch
*
* (c) 2015, Valera Leontyev (feedbee@gmail.com)
*/
$branch = 'master';
@feedbee
feedbee / keyboard-navigation.js
Last active December 14, 2015 03:39
Keyboard navigation for www.tema.ru/travel/* pages. [Z] key navigates to next block (text&photo), [A] navigates to previous block. [X] and [S] used to switch slideshow images (next/previous respectively). Using this script keyboard-only navigation into all tema-travels is available. © Valera Leontyev, 2013. Made exclusively for www.tema.ru/travel/.
// v1.5
(function() {
var blockTopOffset = 5, // px
slideshowTopBuffer = 200, // px
$d = $(document),
$p = $('.pole');
// JQuery can't do this job for us correctly (http://stackoverflow.com/a/12902057/570262)
var getWindowHeight = function () {