Skip to content

Instantly share code, notes, and snippets.

View itsjef's full-sized avatar

Anh Tran (Adrian) itsjef

View GitHub Profile
@itsjef
itsjef / giai_thua.py
Last active December 10, 2015 14:08
Hàm tính tích của n số tự nhiên dương đầu tiên (n!)
#!/usr/bin/env python2.7
def factorial(n):
ans = 1
if n == 0 or n == 1:
ans = 1
elif n < 0:
ans = 'no answer'
else:
for i in range(2, n+1):
@itsjef
itsjef / battleship.py
Last active December 10, 2015 15:19
bắn tàu đê \:D/
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from random import randint
board = []
turn = 0
#tạo sân chơi
for x in range(0,5):
@itsjef
itsjef / pygame_test.py
Created January 4, 2013 23:14
Yay! I just created the most boring game in the world -.-
#!/usr/bin/env python2.7
import pygame
import sys
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400,300))
pygame.display.set_caption("Hello World")
while True:
for i in pygame.event.get():
@itsjef
itsjef / array.py
Last active December 14, 2015 17:49
tạo ra 1 cái bảng click click
import pygame
#colors
black = (0 ,0 ,0 )
white = (255,255,255)
blue = (0 ,0 ,255)
green = (0 ,255,0 )
red = (255,0 ,0 )
#width&height
@itsjef
itsjef / test.c
Created July 17, 2013 09:13
Game về từ ngữ các kiểu ....
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 1000
typedef struct dictionary{
char word[20];
char def[50];
float point;
@itsjef
itsjef / regex.md
Last active October 13, 2017 04:42
some RegEx patterns of mine ...

Số dtdd VN

  • Chi tiết: r'^(\+84|0)(8[689]|9\d|(1(2\d|6[2-9]|8[68]|99)))\d{7}$'
  • Thô thiển: r'^(\+84|0)\d{9,10}$'
@itsjef
itsjef / [Guide] How to migrate Linux between two machines.md
Last active August 29, 2015 14:20
Short guide on how to move your Linux distro from a computer to another

##Step 1 - Backup your /home folder

  1. Install Backups tool by typing in the Terminal: sudo apt-get install deja-dup
  2. Backup your /home folder. Default backup is stored in ~/deja-dup folder

##Step 2 - Backup your package list

  1. Backup package list: sudo dpkg --get-selections > PackageList.txt
  2. Backup APT-key: sudo apt-key exportall > RepoKeys.txt
  3. Backup Source folder: sudo cp /etc/apt/sources.list.d source.list.d
  4. Copy all those files to an USB
@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.
@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!!