Skip to content

Instantly share code, notes, and snippets.

View tranch's full-sized avatar
🎯
Focusing

Tranch tranch

🎯
Focusing
View GitHub Profile
@vayn
vayn / eightqueen.php
Created November 3, 2010 07:41
八皇后 Eight Queens PHP
<?php
/*
* 八皇后问题是一个非常有趣的问题,是由德国大数学家高斯首先提出来的。
* 要求在国际象棋的棋盘上放置八个皇后,使她们不能互相攻击。
* 即任何两个皇后不能处在同一行、同一列、同一条斜线上。
*
* 问有多少种不同的摆法?并找出所有的摆法。
*
* 问题分析:
* (1) 满足上述条件的八个皇后,必然是每行一个,每列一个。
@tomasv
tomasv / gist:912242
Created April 10, 2011 10:50
xmonad config with a hack for floating windows
import XMonad
import Data.Monoid
import System.Exit
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
@diogok
diogok / OnlineUsers.php
Created May 4, 2011 19:48
Online Users using PHP and Redis
<?php
include 'predis/predis.phar';
class OnlineUsers {
/* time to consider user online */
private $minutes = 5 ;
function online() {
/* current hour and minute */
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@oodavid
oodavid / README.md
Last active October 11, 2024 00:36 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@fernandoaleman
fernandoaleman / Linux Static IP
Created March 23, 2012 16:20
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@weaverryan
weaverryan / forms.html.twig
Created April 13, 2012 11:26
Some basic Twitter Bootstrap Symfony2 form customizations
{# for twitter bootstrap specifically #}
{% block field_row %}
{% spaceless %}
<div class="control-group {% if errors|length > 0 %}error{% endif %}">
{{ form_label(form, label|default(null)) }}
<div class="controls">
{{ form_widget(form) }}
{{ form_errors(form)}}
</div>
</div>
@excalq
excalq / gist:2961415
Last active March 19, 2024 17:45
Javacript: Set or Update a URL/QueryString Parameter, and update URL using HTML history.replaceState()
// 2024 Update, use URLSearchParams [https://caniuse.com/urlsearchparams]
export function createQueryString2(name: string, value: string, searchParams: any) {
const params = new URLSearchParams(searchParams);
params.set(name, value.toLowerCase());
return params.toString();
}
// ---- Original 2012 version, when browsers really sucked ----
// Explicitly save/update a url parameter using HTML5's replaceState().
@nielsmouthaan
nielsmouthaan / MenuBuilder.php
Created September 22, 2012 10:21
Custom KnpMenuBundle navigation bar twig template to support Font Awesome icons & Twitter bootstrap lay-out
<?php
namespace Acme\HelloBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class MenuBuilder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
@mattetti
mattetti / gist:3798173
Last active August 21, 2024 05:26
async fetching of urls using goroutines and channels
package main
import (
"fmt"
"net/http"
"time"
)
var urls = []string{
"https://splice.com/",