Skip to content

Instantly share code, notes, and snippets.

View ohDaddyPlease's full-sized avatar
:shipit:
pew-pew. pow-pow. paff-paff

Sergius Novikov ohDaddyPlease

:shipit:
pew-pew. pow-pow. paff-paff
  • Siberia
View GitHub Profile
@joshhartman
joshhartman / randomPassword.php
Last active July 7, 2024 09:12
Human Readable Password Generator (Requires PHP 7.1+)
<?php
function randomPassword( $len = 10, $ucfirst = true, $spchar = true ){
/* Programmed by Christian Haensel
* christian@chftp.com
* http://www.chftp.com
*
* Exclusively published on weberdev.com.
* If you like my scripts, please let me know or link to me.
* You may copy, redistribute, change and alter my scripts as
* long as this information remains intact.
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@border
border / long_polling.go
Created September 25, 2012 09:58
long polling for golang
package main
import (
"container/list"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
//One can make use of the following script to generate menus in an animated fashion. There are several ways of creating a menu such as list, drop down and many more.
function makeMenu(items, tags) {
// default tags
tags = tags || ['ul','li'];
var parent = tags[0];
var child = tags[1];
var item, value = '';
for (var i = 0,l = items.length; i < l; i++) {
item = items[i];
@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@codedokode
codedokode / js-task-1.md
Last active July 13, 2024 16:42
Задания на яваскрипт (простые)

Этот урок переехал в мой гитхаб: https://github.com/codedokode/pasta/blob/master/php/exceptions.md - ниже представлена старая версия, потому советую перейти и прочитать новую.


Как использовать исключения в PHP

Если ты изучаешь ООП, ты наверняка натыкался на исключения. В мануале PHP описаны команды try/catch/throw и finally (доступна начиная с PHP 5.5), но не объясняется толком как их использовать. Чтобы разобраться с этим, надо узнать почему они вообще были придуманы.

А придуманы они были, чтобы сделать удобную обработку ошибок.

@stibiumz
stibiumz / CIDR.php
Last active April 30, 2024 14:23 — forked from jonavon/CIDR.php
<?php
/**
* CIDR.php
*
* Utility Functions for IPv4 ip addresses.
* Supports PHP 5.3+ (32 & 64 bit)
* @author Jonavon Wilcox <jowilcox@vt.edu>
* @revision Carlos Guimarães <cvsguimaraes@gmail.com>
* @version Wed Mar 12 13:00:00 EDT 2014
*/
@Yawning
Yawning / orhttp_example.go
Created April 29, 2015 14:41
How to dispatch HTTP requests via Tor in Go.
// To the extent possible under law, the Yawning Angel has waived all copyright
// and related or neighboring rights to orhttp_example, using the creative
// commons "cc0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package main
import (
// Things needed by the actual interface.
"golang.org/x/net/proxy"
@ammario
ammario / ipint.go
Last active May 25, 2024 21:43
Golang IP <-> int conversion
func ip2int(ip net.IP) uint32 {
if len(ip) == 16 {
return binary.BigEndian.Uint32(ip[12:16])
}
return binary.BigEndian.Uint32(ip)
}
func int2ip(nn uint32) net.IP {
ip := make(net.IP, 4)
binary.BigEndian.PutUint32(ip, nn)