Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JayXon
JayXon / cloudSettings
Created March 17, 2020 22:59
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-03-17T22:59:36.165Z","extensionVersion":"v3.4.3"}
@JayXon
JayXon / youku_playlist.js
Last active March 29, 2018 07:49
get all video links from youku playlist
// Run this in the console of that page
[...document.querySelectorAll('.p-drama-grid a.c555')].map(a => a.href.split('?')[0]).join(' ')
@JayXon
JayXon / keypresssignal.c
Created March 20, 2015 05:13
SCTF2014 MISC100
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <stdlib.h>
#include <err.h>
#include <termios.h>
int main(int argc, char *argv[])
{
@JayXon
JayXon / gcd.cpp
Created January 17, 2015 09:57
Greatest Common Divisor
uint64_t gcd(uint64_t n1, uint64_t n2)
{
while (n2)
swap(n1 %= n2, n2);
return n1;
}
@JayXon
JayXon / modexp.c
Last active August 29, 2015 14:13
Modular exponentiation
// return (b ^ e) % m
uint64_t modexp(uint64_t b, uint64_t e, uint64_t m = 1000000007) {
uint64_t r = 1;
while (e) {
if (e & 1)
r = (r * b) % m;
b = (b * b) % m;
e >>= 1;
}
return r;
@JayXon
JayXon / modinv_1000000007.c
Created January 5, 2015 07:00
Modular Multiplicative Inverse of a when m = 1000000007
uint64_t modinv_1000000007(uint64_t a)
{
a %= 1000000007;
uint64_t r = a;
a = (a * a) % 1000000007;
a = (a * a) % 1000000007;
r = (r * a) % 1000000007;
a = (a * a) % 1000000007;
a = (a * a) % 1000000007;
a = (a * a) % 1000000007;
@JayXon
JayXon / quicksort.go
Created April 3, 2014 06:11
dual pivot quicksort is about 10% faster than classic quicksort
// quicksort
package main
import (
"fmt"
"math/rand"
"sort"
"time"
)
@JayXon
JayXon / strcpy.cpp
Created April 3, 2014 06:07
Speed compare between wcscpy, lstrcpyW, while loop and memcpy
#include <iostream>
#include <cstring>
#include <functional>
#include <chrono>
#include <windows.h>
#define N 1024
uint64_t TestTime(std::function<void()> f)
@JayXon
JayXon / pack.cpp
Created April 3, 2014 05:09
#pragma pack test
#include <iostream>
#pragma pack(4)
struct name
{
short a;
char b;
short c;
int d;
short e;