Skip to content

Instantly share code, notes, and snippets.

View ludofleury's full-sized avatar
🐼
Yay

Ludovic Fleury ludofleury

🐼
Yay
View GitHub Profile
@0xjac
0xjac / private_fork.md
Last active April 19, 2024 05:20
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@masak
masak / explanation.md
Last active April 11, 2024 02:50
How is git commit sha1 formed

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <jnthn@jnthn.net>
Date:   Sun Apr 15 16:35:03 2012 +0200

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@nico3333fr
nico3333fr / hama-grid-generator.php
Last active April 5, 2022 15:48
Pixel Art helper script for Hama beads
<?php
// supposed to be a BMP image, as sprites are really small :)
if ( @$_GET['directfile']!='' ){
$img_name = $_GET['directfile'];
}
$resource = imagecreatefrombmp($img_name);
$width = imagesx($resource);
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes
@clintongormley
clintongormley / gist:1088986
Created July 18, 2011 09:19
Create index for partial matching of names in ElasticSearch
# First, create the synonyms file /opt/elasticsearch/name_synonyms.txt
# with the contents:
#
# rob,bob => robert
#
## CREATE THE INDEX WITH ANALYZERS AND MAPPINGS
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
@ludofleury
ludofleury / MysqlContext.php
Last active November 8, 2021 14:41
A Behat Context with a hook to kill the Mysql connections
<?php
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Behat\Symfony2Extension\Context\KernelDictionary;
use Behat\MinkExtension\Context\MinkContext;
class MysqlContext extends MinkContext implements KernelAwareInterface
{
use KernelDictionary;
@naholyr
naholyr / compare.php
Created February 22, 2012 16:27
Extract namespace from a PHP file
<?php
// Works in every situations
function by_token ($src) {
$tokens = token_get_all($src);
$count = count($tokens);
$i = 0;
$namespace = '';
$namespace_ok = false;
while ($i < $count) {