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
if loadfont /boot/grub/font.pf2 ; then
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
fi
set menu_color_normal=white/black
@Hikari9
Hikari9 / serve.cpp
Last active February 16, 2016 11:26
Serve new folder for apache2.
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;
const string SITES_AVAILABLE_DIR = "/etc/apache2/sites-available/";
@Hikari9
Hikari9 / font-responsive.css
Last active March 5, 2016 08:23
Makes font-size of children respond to the container's width, complete with HTML, JS, and CSS
/**
* Font responsive CSS, compiled. Open-source for everyone.
* @author Rico Tiongson
*/
.font-responsive {
display: -webkit-flex;
display: flex;
-webkit-flex-flow: column nowrap;
flex-flow: column nowrap;
@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
@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 / 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 / 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 / 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 / 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 / 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>