Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Mithrandir0x's full-sized avatar

Oriol López Sánchez Mithrandir0x

View GitHub Profile
@Mithrandir0x
Mithrandir0x / .bashrc
Created February 15, 2014 11:57
.bashrc file to remove ANSI escape crap when connecting with PLINK to a ssh session with a Vagrant VM connected over Sublime Text REPL
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Mithrandir0x
Mithrandir0x / Main.java
Last active December 24, 2015 09:39
clientsocket
package clientsocket;
import java.io.*;
import java.net.Socket;
import java.util.Scanner;
/**
*
* @author manel
*/
@Mithrandir0x
Mithrandir0x / math_alg.py
Last active December 19, 2015 08:28
Mathematic Algorithms
def fibonacci(n):
"""A Fibonacci generator"""
x_1, x = 1, 1
while ( x < n ):
yield x
x_1, x = x, x + x_1
def erastothenes_sieve(n):
"""Get all the prime numbers below 'n'"""
sqrtN = math.sqrt(n)
@Mithrandir0x
Mithrandir0x / disable_wifi_hotspot.bat
Last active August 20, 2018 09:30
Two little batch files to create a cozy WiFi hotspot from the laptop Snatched from xda-developers, yet I don't remember the thread. Kudos to the author.
netsh wlan stop hostednetwork
pause
A =
1.000000000000e-01 1.000000000000e-01 1.000000000000e+00
-3.900000000000e+00 1.100000000000e+00 3.200000000000e+00
1.400000000000e+00 1.500000000000e+00 -1.000000000000e+00
c = ( 1.000000000000e-01 1.100000000000e+00 -1.400000000000e+00 )
k = 0
SWAP F0 <=> F1
A =
@Mithrandir0x
Mithrandir0x / gist:4465421
Last active December 27, 2022 11:27
"Find HTML open tags" Regular Expression
// Found at http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454
//
// But beware, HTML cannot be regexed... The end is nigh.
var re = /<([a-z]+) *[^/]*?>/g;
@Mithrandir0x
Mithrandir0x / makeplain.js
Last active December 10, 2015 08:08
So, is it a bad idea to fetch data from "arguments"? (Rotten belches in 3, 2, 1...)
function makeplain(strAccents)
{
if(strAccents==undefined)
return "";
strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = ['A','A','A','A','A','A','a','a','a','a','a','a','O','O','O','O','O','O','O','o','o','o','o','o','o','E','E','E','E','e','e','e','e','e','C','c','D','I','I','I','I','i','i','i','i','U','U','U','U','u','u','u','u','N','n','S','s','Y','y','y','Z','z'];
@Mithrandir0x
Mithrandir0x / GenericObjectDeserializer.java
Created December 29, 2012 08:50
A class created by Brian Nettleton that allows to transform a JSON string to a Map object for GSON. To use it, just register a new Type Adapter for Object.class.
/**
* @author Brian Nettleton
*/
class GenericObjectDeserializer implements JsonDeserializer<Object>
{
@Override
public Object deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
if( json.isJsonNull() ) {
@Mithrandir0x
Mithrandir0x / gist:4357802
Last active December 10, 2015 01:19
Asynchronous ForEach made by Zef Hemel
//http://zef.me/3420/async-foreach-in-javascript
function asyncParForEach(array, fn, callback) {
var completed = 0;
if(array.length === 0) {
callback(); // done immediately
}
var len = array.length;
for(var i = 0; i < len; i++) {
fn(array[i], function() {