Skip to content

Instantly share code, notes, and snippets.

@Humoud
Humoud / simple-python-cheat-sheet.py
Created March 6, 2015 13:15
simple python code - request
# this is a comment
a = 1
print a
print "value of a is: "+ str(a)
# define function, take no arguments, just print
def func1():
@Humoud
Humoud / edit-files.py
Last active August 29, 2015 14:17
Edits / Inserts code into Java files
import glob
import re
import fileinput
# will insert/inject this
code = "\n\t\t\t\tgetSupportActionBar().setDisplayHomeAsUpEnabled(true);\n"
#code += "\t\t\t\tgetSupportActionBar().setCustomView(R.layout.custom_actionbar);\n"
#code += "\t\t\t\tActionBar actionBar = getSupportActionBar();\n"
#code += "\t\t\t\tactionBar.setHomeButtonEnabled(true);\n"
@Humoud
Humoud / index.html
Created May 14, 2015 00:03
Web Tutorial 1
<!DOCTYPE HTML>
<html>
<head></head>
<body>
<h1>Cafe Pizza</h1>
<h3>Coffee and Pizza. Allah!</h3>
<p>Menu:</p>
<ul>
<li>Turkish Coffee 5KD</li>
<li>Pizza 10KD</li>
@Humoud
Humoud / index.html
Created May 16, 2015 21:43
Web Tutorial 2
<!DOCTYPE HTML>
<html>
<head>
<title>Cafe Pizza</title>
</head>
<body>
<h1>Cafe Pizza</h1>
<h3>Coffee and Pizza. Allah!</h3>
<p>Menu:</p>
<ul>
@Humoud
Humoud / index.html
Created June 20, 2015 10:40
Web Tutorial 4
<!DOCTYPE HTML>
<html>
<head>
<title>Cafe Pizza</title>
<style>
body{
margin-left: 30px;
}
#el9ora1{
height: 250px;
@Humoud
Humoud / Tut1.java
Created June 30, 2015 19:51
Java Tutorial 2
// File: Tut1.java
// Every java program must have at least on class
public class Tut1 {
// Every every Java program must have just one main
public static void main(String[] args) {
// "123 ana programmer" is a String
// Java is case-sensitive
// ("123 ana programmer") now the string is passed as an argument
@Humoud
Humoud / spree-models-cheat-sheet.md
Last active February 3, 2023 14:09
A cheat sheet for the models of Spree. Spree is a complete open source e-commerce solution for Ruby on Rails.
@Humoud
Humoud / rails-relation.rb
Last active February 18, 2016 08:52
A cheat sheet for making Rails ActiveRecord relations while using some models from the Spree framework.
##########################################################
# Relationship: One-to-One
# Tables: Instructor - Spree::User
# User has one Instructor
##########################################################
# in app/models/instructor.rb
class Instructor < ActiveRecord::Base
belongs_to :spree_user, :class_name => 'Spree::User'
end
# in migration file:
@Humoud
Humoud / MongoDb.md
Last active February 19, 2016 19:41
A cheat sheet for mongoDB commands and queries.

Mongo DB

Shell Commands

  • List all databases:
db.getMongo().getDBNames();
show databases
show dbs
@Humoud
Humoud / ActiveRecord.md
Last active March 30, 2016 06:45
A cheat sheet for Rail's Active Record.

Assume we have model Car

# Get all cars with color red
Car.where( color: "red" )

Retrieve all users that have field 'company' not nil