Skip to content

Instantly share code, notes, and snippets.

@vans163
vans163 / escape_uri.erl
Created December 21, 2015 22:31
Erlang escape uri for POST request
%escape uri
escape_uri(S) when is_list(S) ->
escape_uri(unicode:characters_to_binary(S));
escape_uri(<<C:8, Cs/binary>>) when C >= $a, C =< $z ->
[C] ++ escape_uri(Cs);
escape_uri(<<C:8, Cs/binary>>) when C >= $A, C =< $Z ->
[C] ++ escape_uri(Cs);
escape_uri(<<C:8, Cs/binary>>) when C >= $0, C =< $9 ->
[C] ++ escape_uri(Cs);
escape_uri(<<C:8, Cs/binary>>) when C == $. ->
@vans163
vans163 / random_mac_address.erl
Created December 21, 2015 21:48
Erlang random mac address
random_mac() ->
string:join([integer_to_list(random:uniform(255), 16) || X <- [1,2,3,4,5,6]], ":").
@vans163
vans163 / fresh_win.bat
Last active December 18, 2017 03:11
fresh windows install
REM Disable UAC
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /f /v "EnableLUA" /t REG_DWORD /d 0
REM Disable Auto Reboot for Windows Update
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /f /v "NoAutoRebootWithLoggedOnUsers" /t REG_DWORD /d 1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /f /v "NoAUAsDefaultShutdownOption" /t REG_DWORD /d 1
REM Device Manager show all devices
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v "DEVMGR_SHOW_NONPRESENT_DEVICES" /t REG_DWORD /d 1
@vans163
vans163 / fresh_init
Last active June 6, 2016 14:34
debian + gnome fresh install
apt-get install --no-install-recommends xorg gdm3 \
gnome-shell gnome-session gnome-control-center gnome-keyring gnome-shell-extensions gnome-tweak-tool \
gksu dconf-editor gtk2-engines-murrine pulseaudio pavucontrol fonts-cantarell
apt-get install --no-install-recommends thunar thunar-archive-plugin file-roller tumbler \
leafpad gnome-terminal gpicview gnome-system-monitor
apt-get install --no-install-recommends fonts-noto fonts-dejavu fonts-dejavu-extra fonts-droid-fallback fonts-noto-mono \
gnome-accessibility-themes gnome-screenshot gnome-themes-standard gnome-themes-standard-data nautilus