Skip to content

Instantly share code, notes, and snippets.

View AdrienLemaire's full-sized avatar

Adrien Lemaire AdrienLemaire

View GitHub Profile
# def change(array_of_denominations, amount): ==> Number of ways you can make change
# """
# change([1, 5], 6) => 2
# change([1, 5], 10) => 3
# """
def change(array_input, amount):
if amount == 0:
return 1
elif amount < 0 or len(array_input) == 0:
@AdrienLemaire
AdrienLemaire / sqli8_blind_injection.py
Last active September 19, 2015 03:12
Blindly retrieve table, columns and rows informations in a database with bitwise comparisons
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
$ ./sqli8_blind_injection.py -u http://172.28.128.3:8007/membre.php\?id\=7 -e Mickey
OtherInformation:
* idusers
-> 7,8,9,10,11
* useyourname
-> Mickey,Kenshin,Jin,Camus,Pierre
* position
@AdrienLemaire
AdrienLemaire / blind_injection_sqli9
Created September 17, 2015 08:19
using the benchmark sql function to blindly find the right password
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
$ ./sqli9_bf.py
The password is 'bfmoisitupeux'
"""
@AdrienLemaire
AdrienLemaire / autofeed_pets.js
Last active August 29, 2015 14:26
Habitica Auto-feed pets
window.confirm=function(){return true};$.each($(".pet-button"),function(){s=$(this).scope();if(!s.cp){s.cp=s.choosePet.bind({});s.choosePet=function(e,p){f=s.selectedFood.key;nb=Math.min((50-s.user.items.pets[e+"-"+p])/5,s.user.items.food[f]);for(i=0;i<nb;i+=1){s.cp(e,p);s.chooseFood(f)}}}})
@AdrienLemaire
AdrienLemaire / autocast_mana.js
Created August 1, 2015 03:44
Habitica Auto-cast mana
s=angular.element($0).scope();for(i=0;i<s.user.stats.mp/s.skill.mana;i+=1){setTimeout(function(){s.castStart(s.skill);},i*2000);}
@AdrienLemaire
AdrienLemaire / get_mem_for_item.py
Created November 13, 2014 07:56
[Memrise] Get Mnemonic url for word id
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
'''
Find your item id (by looking at your webpage source), and query as follow:
$ ./get_mem_for_item.py -i 41006508
http://www.memrise.com/mem/4321815/i-intend-to-become-a-lawyer/
$
@AdrienLemaire
AdrienLemaire / benchmark_ndarray_N_highest_vals_indices.py
Last active November 11, 2017 16:24
Benchmark 2 methods to get the indices for a multi-dimensional array N highest values
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# $ benchmark.py
#
# Test with test_argpartition:
# Results:
# [[78 55 72]
# [ 0 50 15]
# [ 8 44 27]
@AdrienLemaire
AdrienLemaire / notification_timer
Created August 25, 2014 05:32
notification_timer
#!/bin/bash
# Notification timer, to drop in ~/bin/
function timer () {
while [ "$(date "+%H:%M")" != "$exec_time" ]
do
sleep 60
done
notify-send -i dialog-warning "$title" "$message"
@AdrienLemaire
AdrienLemaire / fabric.plugin.zsh
Created December 27, 2011 05:50
zsh-completion for Fabric in Oh-my-zsh
#compdef fab
_targets() {
_describe -t commands "fabric targets" target_list
}
output_levels=(
'status: Status messages, i.e. noting when Fabric is done running, if the user used a keyboard interrupt, or when servers are disconnected from. These messages are almost always relevant and rarely verbose.'
'aborts: Abort messages. Like status messages, these should really only be turned off when using Fabric as a library, and possibly not even then. Note that even if this output group is turned off, aborts will still occur – there just won’t be any output about why Fabric aborted!'
'warnings: Warning messages. These are often turned off when one expects a given operation to fail, such as when using grep to test existence of text in a file. If paired with setting env.warn_only to True, this can result in fully silent warnings when remote programs fail. As with aborts, this setting does not control actual warning behavior, only whether warning messages are printed or hidden.'
@AdrienLemaire
AdrienLemaire / fab_coverage.py
Created October 19, 2011 06:04
fab coverage
""""
Required: fabric, django, coverage, django-coverage, termcolor
""""
from coverage.misc import CoverageException
from termcolor import colored
def coverage(html=1):
"""Run coverage tests with html output, or
or return only the coverage percentage::