Skip to content

Instantly share code, notes, and snippets.

View golman's full-sized avatar
🐾
у меня лапки

George Golman golman

🐾
у меня лапки
View GitHub Profile
@golman
golman / weather.go
Created March 24, 2020 20:22
geekbrains golang вебинар: «Продолжаем с Go: пишем сканер погоды» — https://geekbrains.ru/events/1867
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
)
@golman
golman / browsers.js
Created October 10, 2018 07:11
detect browsers by duck-typing
// from https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser/9851769
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
@golman
golman / yota.md
Created July 30, 2017 09:28
Yota Internet sharing from iPhone
macOS
sudo sysctl -w net.inet.ip.ttl=65
linux

in terminal:

sudo vi /etc/init.d/local.autostart
@golman
golman / gist:7fe4d2a56e89c9d77448
Last active August 29, 2015 14:05
base_url для CodeIgniter, независимый от домена
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
@golman
golman / gist:7560022
Created November 20, 2013 09:03
digits-only input
$('.digits-only').keyup(function(){
if(this.value != $(this).data('last-value') && this.value.length > 0){
this.value = this.value.replace(/[^0-9]/g,'');
$(this).data('last-value', this.value);
}
});
@golman
golman / gist:5943628
Created July 7, 2013 14:21
jQuery: Close PopUp
$("body").click(function(e) {
if ($(e.target).closest(".popup").length==0) $(".popup").css("display","none");
});
@golman
golman / gist:5943615
Created July 7, 2013 14:18
Centering Percentage Width/Height Elements
.center {
position: absolute;
left: 50%;
top: 50%;
/*
Nope =(
margin-left: -25%;
margin-top: -25%;
*/
@golman
golman / gist:5564564
Created May 12, 2013 19:10
Display file sizes next to download links
// Loop all .fetchSize links
$('a.fetchSize').each(function(){
// Issue an AJAX HEAD request for each one
var link = this;
$.ajax({
type: 'HEAD',
url: link.href,
complete: function(xhr){