Skip to content

Instantly share code, notes, and snippets.

View steve0hh's full-sized avatar

steve steve0hh

View GitHub Profile
@steve0hh
steve0hh / abcd.html
Created February 28, 2019 11:11
chrome_rt
<!DOCTYPE html>
<html>
<head>
<title>abcd</title>
<script charset="utf-8">
function httpGet(theUrl){
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl );
xmlHttp.send( null );
}
@steve0hh
steve0hh / hide_input.py
Created November 27, 2017 16:00
[ipython notebook tricks] Creates a link which toggles the input cells
from IPython.display import HTML
HTML("""
<script>
var code_show=true; //true -> hide code at first
function code_toggle() {
if (code_show){
$('div.input').hide();
@steve0hh
steve0hh / random_number_generator.py
Created October 30, 2017 07:05
How to generate random numbers using maths (Python)
import time as time
# Learning from https://medium.com/delta-force/how-computers-make-random-numbers-51e8938d9d53
def x(n):
a = 1664525 # a-1 must be divisible by all prime factors of m
# a-1 must be divisible by 4 if m is divisible by 4
# Hull-Dobell theorem
m = 2 ^ 32 # m and c has to be co-prime
c = 1013904223
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
while(in.hasNext()){
int input = in.nextInt();
if(input == 42){ break;}
System.out.println(input);
@steve0hh
steve0hh / phoenix.projectionist.json
Created August 30, 2017 07:33
Projectionist collection
{
"README.md": {"type": "doc"},
"lib/PROJECTNAME_web/router.ex": {"type": "route"},
"lib/PROJECTNAME/**.ex": {"type": "context"},
"lib/PROJECTNAME_web/controllers/*.ex": {"type": "controller"},
"lib/PROJECTNAME_web/views/*.ex": {"type": "view"},
"lib/PROJECTNAME_web/templates/*.html.eex": {"type": "template"},
"lib/PROJECTNAME/*.ex": {"alternate": "test/PROJECTNAME/{}_test.exs"},
"test/PROJECTNAME/*_test.exs": {"alternate": "lib/PROJECTNAME/{}.ex"},
"lib/PROJECTNAME_web/*.ex": {"alternate": "test/PROJECTNAME_web/{}_test.exs"},
@steve0hh
steve0hh / phoenix.yml
Last active August 6, 2017 07:08
standard phoenix tmuxinator template
# This file is a configuration file for tmuxinator(https://github.com/tmuxinator/tmuxinator)
name: project_name
root: ~/code/project_name
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start
@steve0hh
steve0hh / nus-fyp-presentation-tips.md
Created April 15, 2016 08:12 — forked from weitsang/nus-fyp-presentation-tips.md
Tips for School of Computing Final Year Project Presentation.

FYP Final Presentation

Basic Principles

  • Show the examiners, and make them understand, clearly what you have achieved after about 400 hours of work over two semesters.
  • Demonstrate to the examiners that you know very well what you have done.
  • Keep the examiners happy.

Slides

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" media="all">
#iframe{
zoom: 2;
}
</style>
#import <Foundation/Foundation.h>
@interface Constants : NSObject
FOUNDATION_EXPORT NSString *const MyFirstConstant;
FOUNDATION_EXPORT NSString *const MySecondConstant;
@end
@steve0hh
steve0hh / horizontal-table.html.erb
Last active December 23, 2015 15:39
table snippet that displays data in tables horizontally
<table class="table table-bordered">
<thead>
<tr>
<th colspan="6"><%= @itinerary.name %></th>
</tr>
</thead>
<tbody>
<% @itinerary.timings.in_groups_of(6) do |timings_row| %>
<tr>
<% timings_row.each do |timing| %>