Skip to content

Instantly share code, notes, and snippets.

Avatar
😄
( ´ ▽ ` )ノ

Lequn Chen abcdabcd987

😄
( ´ ▽ ` )ノ
View GitHub Profile
@abcdabcd987
abcdabcd987 / prog2_abp.c
Created Apr 28, 2017
Programming Assignment #2: Implementing a Reliable Transport Protocol (Alternating-Bit-Protocol)
View prog2_abp.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ******************************************************************
ALTERNATING BIT AND GO-BACK-N NETWORK EMULATOR: VERSION 1.1 J.F.Kurose
This code should be used for PA2, unidirectional or bidirectional
data transfer protocols (from A to B. Bidirectional transfer of data
is for extra credit and is not required). Network properties:
@abcdabcd987
abcdabcd987 / PortraitStyleTransfer.py
Created Apr 13, 2017 — forked from titu1994/PortraitStyleTransfer.py
Partial implementation of "Painting Style Transfer for Head Portraits using Convolutional Neural Networks".
View PortraitStyleTransfer.py
from scipy.misc import imread, imresize, imsave
from scipy.optimize import fmin_l_bfgs_b
import numpy as np
import time
import os
import argparse
import h5py
from keras.models import Sequential
from keras.layers.convolutional import Convolution2D, ZeroPadding2D, AveragePooling2D, MaxPooling2D
@abcdabcd987
abcdabcd987 / c2nasm.bash
Last active Dec 11, 2019
C to NASM Assembly
View c2nasm.bash
#!/bin/bash
# thanks to http://stackoverflow.com/a/20743090
# thanks to https://github.com/diogovk/c2nasm
# install objconv: https://github.com/vertis/objconv
#
# $1: source code
set -e
C_FILE="$1"
BASE_NAME="${C_FILE%.*}"
View del_user.sh
#!/bin/bash
# save as /root/del_user.sh
USERNAME=$1
if [[ -z "$USERNAME" ]]; then
echo "Please give me a username"
exit 1
fi
echo "This script will"
View atomically_replace_vector.cc
#include <atomic>
#include <memory>
#include <vector>
#include <thread>
#include <cstdio>
std::shared_ptr<std::vector<int>> v;
void read(const char* name) {
auto localv = std::atomic_load_explicit(&v, std::memory_order_acquire);
View evalrpc_ipc_trace.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abcdabcd987
abcdabcd987 / TeeOutputStream.java
Created Apr 24, 2016
Write to multiple OutputStream
View TeeOutputStream.java
package com.abcdabcd987.compiler2016.Utility;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.List;
/**
* Created by abcdabcd987 on 2016-04-18.
*/
View flatEnumerate.py
def flatEnumerate(obj, prefix='root'):
if isinstance(obj, int):
return [{ prefix: obj }]
elif isinstance(obj, list):
res = []
for option in obj:
res.extend(flatEnumerate(option, prefix))
return res
elif isinstance(obj, dict):
if len(obj) == 0: return [{}]
@abcdabcd987
abcdabcd987 / chess_sample_ai.cc
Last active Nov 28, 2015
Sample AI for Programming Fall 2015
View chess_sample_ai.cc
#include <ctime>
#include <cstdlib>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
const int H = 4;
const int W = 8;
@abcdabcd987
abcdabcd987 / calc_password.js
Created Sep 25, 2015
using pbkdf2 to hash password (node.js)
View calc_password.js
// See: http://stackoverflow.com/questions/17218089/salt-and-hash-using-pbkdf2
// See: https://crackstation.net/hashing-security.htm
'use strict';
let Promise = require('bluebird');
let crypto = require('crypto');
function calcPassword(password) {
const RANDOM_BYTES = 64;