Skip to content

Instantly share code, notes, and snippets.

@ctrngk
ctrngk / BasicERC20.sol
Created August 4, 2021 14:20 — forked from staringispolite/BasicERC20.sol
Basic ERC20 implementation
pragma solidity >=0.4.22 <0.6.0;
contract ERC20Basic {
string public constant name = "JonCoin";
string public constant symbol = "JH";
uint8 public constant decimals = 18;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
@ctrngk
ctrngk / server.conf
Created December 31, 2020 12:16 — forked from iliakan/server.conf
Nginx configuration for separated frontend and backend endpoints
upstream example-webpack {
server 127.0.0.1:8080;
}
upstream example-backend {
server 127.0.0.1:3000;
}
server {
listen 80;
@ctrngk
ctrngk / anki_algorithm.js
Last active October 1, 2020 02:24 — forked from riceissa/anki_algorithm.py
my current understanding of Anki's spacing algorithm
// https://gist.github.com/riceissa/1ead1b9881ffbb48793565ce69d7dbdd
// "New cards" tab
const NEW_STEPS = [15, 25, 35] // in minutes
const GRADUATING_INTERVAL = 15 // in days
const EASY_INTERVAL = 4 // in days
const STARTING_EASE = 2.50 // in percent
// "Reviews" tab
@ctrngk
ctrngk / Python TCP Client Example.py
Created February 11, 2020 04:25 — forked from Integralist/Python TCP Client Example.py
Python TCP Client Server Example
import socket
hostname, sld, tld, port = 'www', 'integralist', 'co.uk', 80
target = '{}.{}.{}'.format(hostname, sld, tld)
# create an ipv4 (AF_INET) socket object using the tcp protocol (SOCK_STREAM)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connect the client
# client.connect((target, port))
@ctrngk
ctrngk / t.m
Created October 9, 2018 11:37 — forked from amitu/t.m
changing mac input source (language)
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
/*###############################################################################
# #
# changeInput #
# #
# author: Stefan Klieme (based on an idea by Craig Williams) #
# created: 2009-11-05 #
# Changes input language #
# Usage: changeInput prints current input language #
/* Trivial keyboard input layout to english switcher by Alexander V. Zhouravlev.
* Compile it with gcc -framework Carbon -o SwitchToEnglish SwitchToEnglish.m */
#import <Carbon/Carbon.h>
int main (int argc, const char *argv[])
{
TISInputSourceRef english = TISCopyInputSourceForLanguage(CFSTR("en-US"));
if (!english)
return 1;
@ctrngk
ctrngk / ShadowsocksRandomMultiport
Created September 23, 2018 10:10
shadowsocks多端口随机
#ss-server 服务端(假设你的目前的服务端 ss 端口已经监听在 23 端口):
#-----------开始--------------
iptables -t nat -A PREROUTING -p tcp -m multiport --dport 81:1023 -j REDIRECT --to-ports 23
iptables -t nat -A PREROUTING -p udp -m multiport --dport 81:1023 -j REDIRECT --to-ports 23
#以下两条命令可选
service iptables save
service iptables restart
#-----------结束--------------
#ss-redir 本地端(104.224.156.199 自行修改成自己服务器 ip):
@ctrngk
ctrngk / osx_automount_nfs.md
Created June 19, 2018 16:17 — forked from L422Y/osx_automount_nfs.md
Automounting NFS share in OS X into /Volumes

I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:

/etc/auto_master (see last line):

#
# Automounter master map
#

+auto_master # Use directory service

@ctrngk
ctrngk / remove_tuxera.sh
Created June 19, 2018 12:06 — forked from miguelmota/remove_tuxera.sh
Completely uninstall and remove Tuxera NTFS on MacOs (resets trial version)
rm -rf /Applications/Tuxera\ Disk\ Manager.app
rm -rf /Library/Application\ Support/Tuxera\ NTFS
rm -rf /Library/Filesystems/fusefs_txantfs.fs
@ctrngk
ctrngk / info.md
Created June 12, 2018 16:54 — forked from marteinn/info.md
Using the Fetch Api with Django Rest Framework

Using the Fetch Api with Django Rest Framework

Server

First, make sure you use the SessionAuthentication in Django. Put this in your settings.py

# Django rest framework
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
 'rest_framework.authentication.SessionAuthentication'