Skip to content

Instantly share code, notes, and snippets.

View maltzsama's full-sized avatar
💭
Göteborgs

maltzsama

💭
Göteborgs
View GitHub Profile
@maltzsama
maltzsama / processtst.py
Created April 17, 2013 14:47
Python subprocess.check_call([''])
#!/usr/bin/env python
>>>import subprocess
>>>subprocess.check_call(['false'])
#Todos sabemos que não existe um comando false. Logo este comando retornará um erro na tela. Da seguinte forma:
#A saída do da execução desse comando será
Traceback (most recent call last):
File "subprocess_check_call.py", line 11, in <module>
subprocess.check_call(['false'])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.
@maltzsama
maltzsama / kernelarch.sh
Created April 17, 2013 14:55
compile arck linux kernel
#1: Tenham certeza que tem o ABS instalado em suas máquinas.
pacman -Sy abs --nonconfirm
#2: Depois como sudo rodem o ABS (isso pode demorar um pouco).
abs
#3: Crie um diretório temporário para seu novo pacote nvidia.
mkdir -p /var/abs/local/
#4: Faça uma cópia do conteúdo do diretório nvidia.
@maltzsama
maltzsama / kernelcomp.sh
Created April 17, 2013 15:48
compile kernel debian
#1: Instalar pacotes necessários para a compilação do kernel
#Antes de começar você precisa ter certeza que possui as ferramentas de desenvolvimento para que se possa compilar o kernel. Se nao tiver use o comando abaixo.
aptitude install gcc make
#2: Download do kernel versão 2.6.31
wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2
#3: Descompactar o arquivo tar (tar.bz2)
tar -xvvjf -C /usr/src
@maltzsama
maltzsama / kernelarchcomp.sh
Created April 17, 2013 15:53
compile kernel arch linux
#1: Download do kernel
#Faça o download do site oficial do kernel
wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2
#2: Instalar pacotes necessários para compilação:
#Se precisar de mais um pacote instale. Mas acredito que sejam apenas esses dai mesmo.
pacman -S gcc make libtools patch
#3: Descompactar o kernel
#A pasta preferencial é a /usr/src mas vc pode descompactar em outra pasta qualquer
@maltzsama
maltzsama / debianflash.sh
Created April 17, 2013 16:07
install debian on flash drive
#1: Identificação do seu pendrive.
#Identifique em que porta seu pendrive foi reconhecido. Como fazer isso? Deve ser alguma coisa /dev/sdx.
apt-get install hwinfo
hwinfo --short --disk
#disk:
#/dev/sdb Kingston DataTraveler 2.0
#/dev/sda TOSHIBA MK1652GS
#2: Zere o pendrive.
#Para não ter problema vamos formata-lo, ou melhor zerá-lo.
@maltzsama
maltzsama / dicpy.py
Last active December 16, 2015 12:48
Dictionary using pyton
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#Definicion of {"YEAR":} dict
#"Value" of year is another dict
#So we have {"YEAR"":{}}
#another dict have:
#{
#"Key1":["VALUE1"],
#"Key2":["VALUE2"],
#"Key3": ["VALUE3"]
@maltzsama
maltzsama / LowerCase.py
Created April 24, 2013 21:14
Lowercase Challenge Description: Given a string write a program to convert it into lowercase. Input sample: The first argument will be a text file containing sentences, one per line. You can assume all characters are from the english language. e.g. HELLO CODEEVAL This is some text Output sample: Print to stdout, the lowercase version of the sent…
#!/usr/bin/env python
import sys
if (len(sys.argv) >= 2):
fi = open(sys.argv[1], 'r')
for i, n in enumerate(fi.readlines()):
print n.rstrip().lower()
fi.close()
@maltzsama
maltzsama / PrimePalindrome.py
Created April 24, 2013 21:15
Challenge Description: Write a program to determine the biggest prime palindrome under 1000. Input sample: None Output sample: Your program should print the largest palindrome on stdout. i.e. 929
#!/usr/bin/env python
def isprime(n):
for x in xrange(2, int(n**0.5)+1):
if n % x == 0:
return False
return True
def palindrome(n):
if str(n) == str(n)[::-1]:
return True
@maltzsama
maltzsama / FizzBuzz.py
Created April 24, 2013 21:16
Fizz Buzz Challenge Description: Players generally sit in a circle. The player designated to go first says the number "1", and each player thenceforth counts one number in turn. However, any number divisible by 'A' e.g. three is replaced by the word fizz and any divisible by 'B' e.g. five by the word buzz. Numbers divisible by both become fizz b…
#!/usr/bin/env python
import sys
if (len(sys.argv) >= 2):
fi = open(sys.argv[1], 'r')
for i, n in enumerate(fi.readlines()):
x = n.rstrip()
@maltzsama
maltzsama / gist:5602351
Created May 17, 2013 22:17
Saving n Retrieving Data Using NSUserDefaults
//Saving
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// saving an Object
[prefs setObject:Object forKey:@"keyObject"];
// saving an NSInteger
[prefs setInteger:42 forKey:@"keyInt"];
// saving a Double