Skip to content

Instantly share code, notes, and snippets.

View itsjef's full-sized avatar

Anh Tran (Adrian) itsjef

View GitHub Profile
set-option -ga terminal-overrides ",xterm-256color:Tc"
# plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Tmux uses a 'control key', let's set it to 'Ctrl-s'
# Reason: 'Ctrl-s' is easier to reach than 'Ctrl-b'
@itsjef
itsjef / introrx.md
Created May 23, 2017 03:30 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@itsjef
itsjef / TapButton2.md
Last active November 23, 2016 02:12
Cách đổi double-tap trên touchpad thành middle-click trong Cinnamon/Gnome DE
  1. Cài dconf-editor

  2. Vào org.gnome.settings-daemon.plugins.mouse, bỏ tick mục Active. Thoát.

Nếu là Cinnamon thì nằm ở org.cinnamon.settings-daemon.plugins.mouse

  1. Tạo file synaptics config:

sudo mkdir /etc/X11/xorg.conf.d

@itsjef
itsjef / singleton.py
Last active November 25, 2016 03:08
The Sublime Singleton
def singleton(cls):
instance = cls()
instance.__call__ = lambda: instance
return instance
@singleton
class A:
def __init__(self):
self.x = 10
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# vim:ts=2:sw=2:expandtab
import os
import xcb
from xcb.xproto import *
from PIL import Image
XCB_MAP_STATE_VIEWABLE = 2
def func1(arr, output = [], i = 0)
if i == arr.length
output << arr # <= RING DING DING
else
for j in 0...arr.length
arr[j] = i
func1(arr, output, i+1) if arr[1].odd?
end
end
output
@itsjef
itsjef / Oauth2.md
Created June 22, 2016 17:33 — forked from mziwisky/Oauth2.md
Oauth2 Explanation

OAUTH2

The Problem

I’m a web app that wants to allow other web apps access to my users’ information, but I want to ensure that the user says it’s ok.

The Solution

I can’t trust the other web apps, so I must interact with my users directly. I’ll let them know that the other app is trying to get their info, and ask whether they want to grant that permission. Oauth defines a way to initiate that permission verification from the other app’s site so that the user experience is smooth. If the user grants permission, I issue an AuthToken to the other app which it can use to make requests for that user's info.

Note on encryption

Oauth2 has nothing to do with encryption -- it relies upon SSL to keep things (like the client app’s shared_secret) secure.

@itsjef
itsjef / slim-redux.js
Created April 26, 2016 20:32 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@itsjef
itsjef / Why stateful code is bad
Created March 8, 2016 16:49
stateful code is bad
STUDENT: Sir, can I ask a question?
TEACHER: Yes!
STUDENT: How do you put an elephant inside a fridge?
TEACHER: I don't know.
STUDENT: It's easy, you just open the fridge and put it in. I have another question!
TEACHER: Ok, ask.
STUDENT: How to put a donkey inside the fridge?
TEACHER: It's easy, you just open the fridge and put it in.
STUDENT: No sir, You just open the fridge take out the elephant and put it in.
TEACHER: Ooh...ok!!
@itsjef
itsjef / Dính surfvox thì làm gì?.md
Last active August 29, 2015 14:23
Một ngày đẹp trời, vào Windows mở browser ra định lên mạng chơi thì thấy trang chủ là www.surfvox.com, search engine cũng bị đổi thành surfvox, mở Task Manager không được, Msconfig, Regedit cũng không được. Vậy phải làm gì?

Surfvox nói chung là một search engine nhưng hành xử như cc, cài đặt ngầm, chạy ngầm, hijack browser và ngăn chặn gỡ bỏ.

Dính Surfvox, máy sẽ có các triệu chứng như:

  • Homepage mặc định và search engine bị đổi thành surfvox.com (duh)
  • Không thể mở Task Manager, Regedit, Msconfig, thậm chí google từ khóa nvxasync (file chạy và chiếm quyền của surfvox)
  • Không thể cài đặt các chương trình diệt malware, adware, CCleaner, YourUninstaller ... Các file exe của surfvox nói chung nằm trong %APPDATA%/nvxasync nhưng vào cmd gõ dir và del đều không có tác dụng.

Để hốt con sâu này ta cần:

  • Một Task Manager khác do Task Manager mặc định đã bị vô hiệu hóa: Process Hacker.