Skip to content

Instantly share code, notes, and snippets.

View adrianmarkperea's full-sized avatar

Adrian Mark Clave Perea adrianmarkperea

View GitHub Profile
@adrianmarkperea
adrianmarkperea / state_engine.py
Created June 14, 2018 02:00 — forked from iminurnamez/state_engine.py
Simple state engine example
#This code is licensed as CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/legalcode).
import sys
import pygame as pg
class Game(object):
"""
A single instance of this class is responsible for
managing which individual game state is active
" ---------------------USABILITY CONFIGURATION---------------------
" don't make vim compatible with vi
set nocompatible
" turn on syntax highlighting
syntax on " and show line numbers
set number
" turn on wild menu
@adrianmarkperea
adrianmarkperea / build.sh
Created October 3, 2018 09:06
Interfaces with Jenkins API to build dev boxes from command line
#!/usr/bin/env bash
if [ -z $1 ]
then
echo "DNS not found. Defaulting to aperea"
DNS="aperea"
else
DNS="$1"
fi
@adrianmarkperea
adrianmarkperea / random_dataframe.py
Created September 30, 2019 12:39
Random DataFrame
0 1 2 3
0 0.850004 0.206778 0.655200 0.079339
1 0.948567 0.749701 0.116241 0.069551
2 0.834722 0.360724 0.410327 0.535236
3 0.221309 0.916424 0.649175 0.803750
PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabin Embarked
1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S
2 1 1 Cumings, Mrs. John Bradley (Florence Briggs Thayer) female 38 1 0 PC 17599 71.2833 C85 C
3 1 3 Heikkinen, Miss. Laina female 26 0 0 STON/O2. 3101282 7.925 S
4 1 1 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35 1 0 113803 53.1 C123 S
5 0 3 Allen, Mr. William Henry male 35 0 0 373450 8.05 S
6 0 3 Moran, Mr. James male 0 0 330877 8.4583 Q
7 0 1 McCarthy, Mr. Timothy J male 54 0 0 17463 51.8625 E46 S
8 0 3 Palsson, Master. Gosta Leonard male 2 3 1 349909 21.075 S
9 1 3 Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) female 27 0 2 347742 11.1333 S
my_list = []
if not my_list:
print('List is empty')
# This could also work, but is unnecessary
if len(my_list) == 0:
print('List is empty')
my_list.append(1)
fruits = ['apples', 'oranges', 'bananas']
# yikes, archaic
for i in range(len(fruits)):
print(i, fruits[i])
# So much better
for i, fruit in enumerate(fruits):
print(i, fruit)
# Record yourself trying to type this
categories = ['A', 'B', 'C', 'D', 'B', 'A', 'C', 'C', 'A']
# Over this
categories = list('ABCDBACCA')
# say you have a pair of cartesian coordinates x and y
x = 1
y = 16
# you can `pack` them into a tuple like so
point = x, y
print(point) # => (1, 16)
# and `unpack` them like so
new_x, new_y = point
# Let's create a madlib
year = 2016
event = 'a party with Barrack Obama'
adverb = 'hella'
adjective = 'amazing'
# No, that's not a typo.
# Add 'f' before your strings to make them into f-strings
print(f'It was back in {year} when we had {event}. It was {adverb} {adjective}.')
# => It was back in 2016 when we had a party with Barrack Obama. It was hella amazing.