Skip to content

Instantly share code, notes, and snippets.

@Tydus
Tydus / FortuneCookie.js
Last active October 13, 2023 18:33
FortuneCookie.js
Game.Win('Third-party');
if(FortuneCookie === undefined) var FortuneCookie = {};
if(typeof CCSE == 'undefined') Game.LoadMod('https://klattmose.github.io/CookieClicker/' + (0 ? 'Beta/' : '') + 'CCSE.js');
FortuneCookie.name = 'Fortune Cookie';
FortuneCookie.version = '2.17';
FortuneCookie.GameVersion = '2.022';
FortuneCookie.launch = function(){
FortuneCookie.init = function(){
FortuneCookie.isLoaded = 1;
@Tydus
Tydus / CookieMonster.js
Created December 19, 2019 14:16
CookieMonster.js
/**********
* Header *
**********/
CM = {};
CM.Backup = {};
CM.Cache = {};
@Tydus
Tydus / ifrename.sh
Last active October 29, 2017 12:09
Rename ethx and wlanx to persistent names for OpenWrt
#!/bin/sh
# ifrename.sh: rename ethx and wlanx to persistent names
# Dependency: ip ethtool
# See also: https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-net_id.c
# TODO: currently only support pci-e devices
ip -br l | cut -d' ' -f1 | while read i; do
prefix=$(echo "$i" | cut -c-2)
@Tydus
Tydus / config_vwifi.sh
Created December 7, 2016 14:38
config virtual wi-fi APs
#!/bin/sh
#=======================================
# config_vwifi.sh
# Config virtual wi-fi (bridge to vlans)
#=======================================
# show which port you have by `robocfg show'
PORT_LIST="0t 1t 2t 3t 4t 8t"
@Tydus
Tydus / mnist.py
Last active November 4, 2016 15:38
mnist.py
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
import tensorflow as tf
sess = tf.InteractiveSession()
weight_variable = lambda shape: tf.Variable(tf.truncated_normal(shape, stddev=0.1))
bias_variable = lambda shape: tf.Variable(tf.constant(0.1, shape=shape))
conv2d = lambda x, W: tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
@Tydus
Tydus / waifu2x.py
Last active May 30, 2022 07:16
waifu2x in 15 lines of Python by @marcan42
import json, sys, numpy as np
from scipy import misc, signal
from PIL import Image
infile, outfile, modelpath = sys.argv[1:]
model = json.load(open(modelpath))
im = Image.open(infile).convert("YCbCr")
im = misc.fromimage(im.resize((2*im.size[0], 2*im.size[1]), resample=Image.NEAREST)).astype("float32")
planes = [np.pad(im[:,:,0], len(model), "edge") / 255.0]
for step in model:
o_planes = [sum([signal.convolve2d(ip, np.float32(kernel), "valid")
@Tydus
Tydus / go
Last active August 29, 2015 14:11
go.py
#!/usr/bin/python2
import sys
import json
import urllib2
import lxml.html
def fetch(url):
ua = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:33.0) Gecko/20100101 Firefox/33.0.2"
return urllib2.urlopen(urllib2.Request(
@Tydus
Tydus / labyrinth_bind.js
Last active April 21, 2021 14:58
fiddler script for labyrinth bind
import System;
import System.Windows.Forms;
import Fiddler;
// INTRODUCTION
// This is the FiddlerScript Rules file, which creates some of the menu commands and
// other features of Fiddler. You can edit this file to modify or add new commands.
//
// The original version of this file is named SampleRules.js and it is in the
// \Program Files\Fiddler\ folder. When Fiddler first starts, it creates a copy named
@Tydus
Tydus / howto-standalone-toolchain.md
Last active May 4, 2023 13:43
How to install Standalone toolchain for Android

HOWTO Cross compiling on Android

5W1H

What is NDK

NDK (Native Develop Toolkit) is a toolchain from Android official, originally for users who writes native C/C++ code as JNI library. It's not designed for compiling standalone programs (./a.out) and not compatible with automake/cmake etc.

What is Standalone Toolchain

"Standalone" refers to two meanings:

  1. The program is standalone (has nothing connect to NDK, and don't need helper scripts to run it)
  2. The toolchain is made for building standalone programs and libs, and which can used by automake etc.

(Optional) Why NDK is hard to use

By default, NDK uses android flavor directory structure when it's finding headers and libs, which is different from GNU flavor, so the compiler cannot find them. For Example:

@Tydus
Tydus / howto-root.md
Last active August 29, 2015 14:00
How to root nexus 7

How to root Nexus 7

What is Rooting

Android has a "jail" that limits user apps to claim its own user and group (one Linux user for one app). The default '/bin/su' program denies the access from these user apps. Thus we need to replace the default su by some 3rd party ones to get root access from apps(as well as adb). That is 'rooting'.

What is unlock

Many manufacturers don't like user to change their system (/, /system, etc.), so they employed a technique called 'BootLoader Lock' which will deny any unauthorized changes to the system partitions. Literally, the "Unlock" procedure will nullify the lock (by some means, be it official or exploiting). As we want to replace the 'su', we first need to unlock the machine.

What is recovery

Recovery is a small, in-memory Linux, which is designed for 'emergency' use (e.g. the main Android system broke down and cannot boot up). Many developers try to make use of the Recovery system, mainly for flashing custom roms, backing up and debugging. Therefore, we ne