Skip to content

Instantly share code, notes, and snippets.

@Xananax
Xananax / WANNACRY.MD
Last active May 15, 2018 14:15
Ransomware instructions

There's a new type of virus spreading right now at high speed through the Internet.

It's called WannaCry.

It render all your files inaccessible, so backup everything! You can catch it simply by being connected.


IN SUMMARY

@Xananax
Xananax / install.sh
Last active February 7, 2020 22:35
After Arch/Antergos install
# Install essential stuff, vim and git
sudo pacman -S vim git --needed
# Get pacserve to speed up the rest of the downloads
mkdir -p ~/resources/aur
cd ~/resources/aur
git clone https://aur.archlinux.org/python3-threaded_servers.git
git clone https://aur.archlinux.org/pacserve.git
cd python3-threaded_servers
@Xananax
Xananax / update-aur.sh
Last active February 24, 2020 05:20
Update all AUR repos
# vi:syntax=sh
#!/usr/bin/env bash
# AUR updated
# Checks all directories for updates, then
# runs makepkg -si for each updated git repo
checkIfRepo(){
stat "$1" > /dev/null || return 1;
cd $1; echo "Checking $1"
git status --porcelain >/dev/null && cd .. || return 1; # A fatal error if $PWD is not a git repos
@Xananax
Xananax / cheerio.js
Last active February 20, 2017 18:14
Scrape Page with Cheerio example
/**
* Example of web page scraping with related pages
* related pages are loaded sequentially, which is slow
* but does not tax the connection.
* this example requires a few modules, so do:
* npm install request cheerio bluebird
* then node cheerio.js to run
* scraped site will be saved to a file 'flat6labs.csv'
**/
var request = require('request');
function getAnAnswerMaybeSomeDay(url,cb){
var willWork = Math.random() > .1
var waitFor = Math.random() * 500
setTimeout(function(){
if(willWork){
cb(null,"réponse")
}else{
cb(new Error("pas de reponse"))
}
},waitFor)
@Xananax
Xananax / 01-overly-complex-fizzbuzz.js
Last active February 2, 2017 21:44
FizzBuzz things
const multiple = m => n => n % m === 0
const getStringIfPredicate = (predicate,str) => n => predicate(n) ? str : ''
const fizz = getStringIfPredicate(multiple(3),'fizz')
const buzz = getStringIfPredicate(multiple(5),'buzz')
const fizzbuzz = n =>
( n
? fizz(n)+buzz(n) || n+''
: '0'
)
// Type definitions for Charm v1.0.1
// Project: https://github.com/substack/node-charm/
// Definitions by: Jad Sarout <https://github.com/Xananax/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module Charm{
type CharmColorName = 'red' | 'yellow' | 'green' | 'blue' | 'cyan' | 'magenta' | 'black' | 'white'
type CharmColorHex = number;
type CharmColor = CharmColorName | CharmColorHex;
@Xananax
Xananax / flatten_array.js
Last active May 27, 2016 17:34
Flatten Array
/************
* UTILITIES *
************/
function throwIfNotArray(arr){
if(isArray(arr)){return true;}
throw new Error(`\`${arr}\` is not an array`);
}
@Xananax
Xananax / lucanor-safe.sh
Created May 13, 2016 04:35
The Count Lucanor Output
$ ./lucanor_safe.sh
Base directory : /home/xananax/.local/share/Steam/steamapps/common/The Count Lucanor
Path : /home/xananax/.local/share/Steam/steamapps/common/The Count Lucanor/jre/bin:/home/xananax/.local/share/Steam/steamapps/common/The Count Lucanor/lib:/home/xananax/.local/share/Steam/steamapps/common/The Count Lucanor:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/xananax/.bin:/home/xananax/.bin
Native path : /home/xananax/.local/share/Steam/steamapps/common/The Count Lucanor/lib
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
[S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.so.
[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunnin
@Xananax
Xananax / deact.js
Created May 1, 2016 20:04
React-like stupid and dirty 180 LOC implementation
"use strict";
function isPlainObject(obj) {
return obj !== null && typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype;
}
exports.isPlainObject = isPlainObject;
function isFunction(obj) {
return obj && (typeof obj == 'function');
}
exports.isFunction = isFunction;
var renderStyle = function (style) {