Skip to content

Instantly share code, notes, and snippets.

View Korko's full-sized avatar

Jérémy Lemesle Korko

View GitHub Profile
@Korko
Korko / cleanup.php
Last active August 29, 2015 13:57
Upload an img and store it locally
#!/usr/bin/php
<?php
$dir = 'tmp/';
$files = scandir($dir);
$delay = time() - 2*60;
foreach($files as $file) {
if(strpos($file, '.png') !== false && filemtime($dir.$file) <= $delay) {
echo $dir.$file."\n";
@Korko
Korko / .bashrc
Last active November 8, 2024 13:58
Some functions to help use of git with CR and stuff by Gerrit
# Git configs
git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto
git config --global color.ui auto
# Git basic aliases
git config --global alias.r reset
git config --global alias.co checkout
@Korko
Korko / circle.js
Created February 7, 2014 11:37
Dynamicaly generate a wheel with links in Javascript from a simple list.
/**
* Construct a circle with links all around it.
* @params links Array of links (JSON Objects with params name and link)
* @params r Integer Radius of the circle
* @params thumSize Integer Max width/height for the thumb
* @params fullSize Integer Max width/height for the image in the center
*
* The first element will be on the left and all others will be in clockwise
*/
var linksWheel = function(links, r, thumbSize, fullSize, innerText) {
@Korko
Korko / minecraft
Last active January 4, 2016 22:09
Minecraft management script : sudo /etc/init.d/minecraft Legendary start => will start /home/minecraft/Legendary/minecraft.jar
#!/bin/bash
# /etc/init.d/minecraft
# version 2015-01-20 (YYYY-MM-DD)
### BEGIN INIT INFO
# Provides: minecraft
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
@Korko
Korko / backup.sh
Created January 29, 2014 10:03
Keep hourly backups and only keep some of them for each day etc.
#!/bin/bash
# Warning, for each of these rules, we keep the oldest ones
# this is required in order to have some files in the oher category
KEEP_DAY=1 # How many to keep for each day (except for the current 24h and more than a week)
KEEP_WEEK=0 # How many to keep over a week old
for i in {1..6} ; do
# Find all files that are older than $i days and younger than ($i+1) days and remove them
@Korko
Korko / cacheData.php
Created October 16, 2013 17:00
Memcache class to manage multiple datas to store later (reduces calls to sql and manage race conditions)
<?php
/**
* Memcache class to manage multiple datas to store later (reduces calls to sql and manage race conditions)
*/
abstract class CacheData extends Memcached {
const ACTION_SET = 'set';
const ACTION_INCREMENT = 'inc';
@Korko
Korko / rename.sh
Created April 15, 2013 21:37
Rename all files in a directory to year_month_day_hour_minutes.ext from date of last modification.
#! /bin/ksh
if [ $# -ne 1 ] ;then
echo "USAGE: $0 <directoryToScan>"
exit 1;
fi
for file in "$1"/* ;do
extension=${file##*.}
@Korko
Korko / randomLikes.php
Last active December 16, 2015 04:29
Simple tool to select a random facebook user who likes a story
<?php
if(!isset($_GET['stories'])) {
die('USAGE : randomLikes.php?stories=&lt;story id,story id...&gt;');
}
$stories = explode(',', $_GET['stories']);
$alldata = array();
foreach($stories as $story) {
@Korko
Korko / index.html
Last active May 11, 2021 21:26
Focus in a textarea in a specific position
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="jquery.focus.js"></script>
<script type="text/javascript">
function showTextarea() {
var rawContent = 'a § b';
var rawCursorPosition = rawContent.indexOf('§');
rawContent = rawContent.replace('§', '');
@Korko
Korko / nested_optgroup.html
Created October 9, 2012 12:58
Try to make nested optgroups
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script type="text/javascript">
$(function() {
$('ul[data-widget=select]').each(function() {
var $select = $('<select>');
$(this).find('li').each(function() {