Skip to content

Instantly share code, notes, and snippets.

@lewtds
lewtds / len.py
Created November 30, 2012 15:28
Python len
#-*- coding: utf-8
a = '123456'
# Cách 1
count = 0
for i in a:
count += 1
print count
#-*- coding: utf-8
import sys
def print_help():
print "Usage: split <file> <number of parts>"
sys.exit()
if len(sys.argv) != 3:
print_help()
#-*- coding: utf-8
import sys
def print_help():
print "Usage: split <file> <number of parts>"
sys.exit()
if len(sys.argv) != 3:
print_help()
import itertools
def is_prime(num):
if num <= 2:
return False
if not num % 2:
return False
i = 3
while i ** 2 <= num:
if not num % i:
#!/usr/bin/env python3
import itertools # Thư viện chuẩn của Python để xử lý các vấn đề lặp, tổ hợp,
# chỉnh hợp,...
def is_prime(num):
if num < 2:
return False
if num == 2:
return True
if not num % 2:
#
# IBus-Censor - The Vietnamese IME for IBus
#
# Copyright (c) 2012- Long T. Dam <longdt90@gmail.com>,
# Trung Ngo <ndtrung4419@gmail.com>
#
# This file is part of IBus-Censor Project
# IBus-Censor is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@lewtds
lewtds / censor.py
Created December 9, 2012 18:02
ibus-censor
#!/usr/bin/env python3
# IBus-Censor - The Censoring IME for IBus
#
# Copyright (c) 2012- Long T. Dam <longdt90@gmail.com>,
# Trung Ngo <ndtrung4419@gmail.com>
#
# This file is part of IBus-Censor Project
# IBus-Censor is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@lewtds
lewtds / gist:4257257
Created December 11, 2012 09:18
Tính tổng các chữ số của 100!
import math
print(sum([x for x in map(int, str(math.factorial(100)))]))
@lewtds
lewtds / io.c
Created December 19, 2012 08:26 — forked from anonymous/io.c
#include "stdio.h"
int main(int argc, char const *argv[])
{
FILE *f;
char buffer[4096];
f = fopen("bits.txt", "w");
while(1) {
fwrite(buffer, 4096, 1, f);
}
return 0;