Skip to content

Instantly share code, notes, and snippets.

View Hikari9's full-sized avatar

Rico Tiongson Hikari9

  • Ateneo de Manila University
View GitHub Profile
@Hikari9
Hikari9 / FINALLAB.jsim
Created November 30, 2015 14:05
CS 152 final lab: f(opcode, z) = (pcsel, ra2sel, bsel, wdsel, alufn, wr, werf)
.include "8clocks.jsim"
.include "nominal.jsim"
.include "stdcell.jsim"
// for alufn connect
.subckt knex a b
.connect a b
.ends
// Subcircuit for final lab
// run this in the k-map solver site in http://www.32x8.com/circuits6 to choose radio buttons
index = 3;
tags = document.getElementsByTagName('input');
radio = {};
// find radio tags
for (i in tags) {
if (tags[i].type == 'radio' && tags[i].name.substring(0, 2) == 'in') {
@Hikari9
Hikari9 / FinalLabMemory.jsim
Created December 1, 2015 04:01
CS 152 final lab using JSIM memory
.include "8clocks.jsim"
.include "nominal.jsim"
.include "stdcell.jsim"
// for alufn connect
.subckt knex a b
.connect a b
.ends
// Xlab opcode[5:0] z pcsel[1:0] ra2sel bsel wdsel[1:0] alufn[5:0] wr werf FINALLAB
@Hikari9
Hikari9 / heavylightuntested.cpp
Created December 4, 2015 03:08
Heavy Light Decomposition Untested
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <ctime>
#include <algorithm>
@Hikari9
Hikari9 / triangle.cpp
Created December 14, 2015 01:32
Count all possible triangles with distinct lengths <= n
#include <iostream>
#include <cstdio>
using namespace std;
int sumsquare(int n) {
return n * (n + 1) / 2 * (2 * n + 1) / 3;
}
int range(int n) {
return n * (n + 1) / 2;
@Hikari9
Hikari9 / hack.cpp
Created February 4, 2016 09:06
Hackerrank HourRank round 5 difficult question, incomplete
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100005;
int n, q; long long k;
char s[N]; int pos[N], sa[N], tmp[N], lcp[N], gap;
@Hikari9
Hikari9 / hover-float.css
Created February 6, 2016 13:08
Hover float CSS script. TODO: hover-float-down, hover-float-right.
.hover-float {
margin-top: 10px !important;
margin-bottom: 0px !important;
}
.hover-float:hover {
margin-top: 0px !important;
margin-bottom: 10px !important;
}
@Hikari9
Hikari9 / global.php
Created February 7, 2016 17:19
Global utilities for PHP
<?php
define('__ROOT__', $_SERVER['DOCUMENT_ROOT']);
define('__MAIN__', $_SERVER['SCRIPT_FILENAME']);
/**
* Checks if needle is string is a prefix of the other string.
* @param string &$haystack
* @param string $needle
* @return string
*/
function starts_with($haystack, $needle) {
@Hikari9
Hikari9 / ftp-mirror.sh
Last active July 8, 2022 16:31
Upload files using FTP
#!/bin/bash
HOST='ftp.domain.com'
USER='[email protected]'
SOURCE='/path/to/folder/with/ending/slash/'
TARGET='/path/to/dest/'
lftp -f "
set ftp:ssl-force false
set ssl:verify-certificate no
open $HOST
@Hikari9
Hikari9 / sass.sh
Created February 14, 2016 23:48
Sass watcher
#!/bin/bash
#Runs sass pre-compiler in directory
# Absolute path to this script, e.g. /var/www/pure-celadon/css/sass.sh
SCRIPT=$(readlink -f "$0")
# Absolute path this script is in, thus /var/www/pure-celadon/css
SCRIPTPATH=$(dirname "$SCRIPT")
# The absolute root path, e.g. /var/www/pure-celadon