Skip to content

Instantly share code, notes, and snippets.

View gwenhael-le-moine's full-sized avatar

gwenhael gwenhael-le-moine

View GitHub Profile
#[...]
# Alt-tab
bindsym Mod1+tab exec ~/.config/sway/alttab.rb
#[...]
@gwenhael-le-moine
gwenhael-le-moine / MyFitnessPal-backup.rb
Last active December 5, 2018 15:28
Full backup of MyFitnessPal food diaries as JSON
#!/usr/bin/env ruby
require 'date'
require 'optparse'
require 'json'
require 'bundler/inline'
gemfile {
source 'https://rubygems.org'
gem 'mechanize'
@gwenhael-le-moine
gwenhael-le-moine / nextcloud-news-updater.rb
Last active August 28, 2018 13:49
update nextcloud's news app feeds in a single ruby script without any dependencies
#!/usr/bin/env ruby
require "json"
require "thwait"
NC_ROOT = "/srv/www/vhosts/nextcloud-server/htdocs".freeze
NB_THREADS = 2
def occ( command )
`php -f #{NC_ROOT}/occ #{command}`
end
#!/bin/sh
CWD=$(pwd)
TMP=/tmp
WPs_ROOT=/home/cycojesus/www
function update_WordPress() {
echo "Treating $1:"
echo -n " - Fixing permissions... "
chown -R apache:apache $1
@gwenhael-le-moine
gwenhael-le-moine / termux-su.sh
Last active October 23, 2022 11:53 — forked from cswl/termux-su
run termux programs as root..
#!/data/data/com.termux/files/usr/bin/sh
# sudo for Termux
# For security reasons some environent variables are reset by su
# So need to set LD_LIBRARY_PATH again
# root's HOME is set to termux's home/.suroot. You can add bashrc there
ROOT_HOME=$HOME/.suroot
var clever_truncate = function( text, length ) {
if ( text.length > length ) {
var result = text.substring( 0, length );
result = result.substring( 0, result.lastIndexOf(' ') );
result += '…';
return result;
} else {
return text;
}
};
@gwenhael-le-moine
gwenhael-le-moine / setup-sshd-on-CM.sh
Created August 4, 2013 11:58
As it says, this script will setup a working configuration to run CM10 (minimum)'s included sshd. It doesn't starts it automatically by default as I prefer to control it using Tasker rules but feel free to uncomment the last 2 lines
#!/system/xbin/bash
# Insipred by http://alainwolf.ch/en/tech-talk/ssh-cyanogenmod/
if [ "$UID" != "0" ]; then
echo "This script _MUST_ be run as root"
exit 1
fi
#creates /data/ssh/ if it doesn't exist
#!/bin/sh
for i in $(git submodule | sed 's|^ |_|g' | cut -d\ -f2); do
(cd $i;
git checkout master && git pull && git push
);
git commit $i -sm "updated submodule $i";
done;
git pull && git push
@gwenhael-le-moine
gwenhael-le-moine / tenniskata1prime.py
Created April 18, 2011 05:34
HanoiLUG CodingDojo 1 Gwh
class TennisGame:
def __init__(self):
self.finish = False
self.who_is_the_winner = 0
self.start()
def start(self):
self.player_score = [ 0, 0 ]
def player_scores(self, player):
#include <stdio.h>
int bsearch( char to_search, char array[], int min, int max )
{
int middle = min + ( ( max - min ) / 2 );
if ( ( min == max ) && ( array[ min ] != to_search ) )
return -1;
if ( array[ min ] == to_search )
return min;
if ( array[ max ] == to_search )