Skip to content

Instantly share code, notes, and snippets.

@z-------------
z------------- / matchesSelector.js
Last active August 29, 2015 14:13
Check if an element matches a CSS selector string
HTMLElement.prototype.matchesSelector = function(selector) {
var clonedElem = this.cloneNode();
var docFrag = new DocumentFragment();
docFrag.appendChild(clonedElem);
return (docFrag.querySelectorAll(selector).length > 0);
};
/*
document.body.matchesSelector("body") // true
*/
@z-------------
z------------- / gourdify.js
Last active August 29, 2015 14:12 — forked from poonl1/gourdify
var gourdify = function(map){
var keys = Object.keys(map);
var ps = document.querySelectorAll("p");
[].slice.call(ps).forEach(function(p){
keys.forEach(function(key){
var regex = new RegExp(key + "\\w+", "gi");
p.innerHTML = p.innerHTML.replace(regex, map[key]);
});
@z-------------
z------------- / better-smart.css
Last active January 22, 2017 11:52
SMART looks like shit. better-smart.css makes it less so. By several orders of magnitude.
body {
font-family: "Segoe UI", "Noto Sans CJK TC", sans-serif;
padding-top: 70px;
}
h1, h2, h3, h4, h5, h6 {
font-family: "Segoe UI", "Noto Sans CJK TC", sans-serif;
text-transform: uppercase;
letter-spacing: -0.03em;
}
import sys
from http.server import CGIHTTPRequestHandler, HTTPServer
port = 8000
if len(sys.argv) > 1:
port = int(sys.argv[1])
handler = CGIHTTPRequestHandler
handler.cgi_directories = ["/py"]
server = HTTPServer(("", port), handler)
@z-------------
z------------- / color.sh
Created December 2, 2014 00:42
Change colors in terminal
#!/bin/bash
black="\033[0;30m"
blue="\033[0;34m"
green="\033[0;32m"
cyan="\033[0;36m"
purple="\033[0;35m"
orange="\033[0;33m"
lightgrey="\033[0;37m"
darkgrey="\033[1;30m"
@z-------------
z------------- / cl-g.py
Last active August 29, 2015 14:10
Command line interface for Google, written in Python
import os
import sys
import webbrowser
from urllib.request import Request, urlopen
import urllib.parse
from bs4 import BeautifulSoup
os.system("clear")
try:
print "Welcome"
name = raw_input("Tell me your name, child\n")
word = raw_input("Enter a random word pl0x\n")
if len(word) > 0 and word.isalpha():
print "You said '%(word)s', %(name)s" % {"word": word, "name": name}
else:
print "ur an fgt"
var yasify = function(string) {
return string.replace(new RegExp("e", "gi"), "a");
};
// yasify("yes") --> "yas"
// yasify("yeya") --> "yaya"
// yasify("doge very wow") --> "doga vary wow"
<section id="introduction">
<h2>Introduction</h2>
<p>We, the Sha Tin College Student Council, are a group consisting of 16 students who are all dedicated to the objective of fostering a unified, harmonious, and equal community.</p>
<p>We are responsible for expressing student voice in the Sha Tin campus by working cohesively with all parties to achieve and implement the goals desired by the student community.</p>
<p>As representatives of the student population, we take any and all opinions in the highest regard with the aim of creating a holistic environment for all.</p>
<img src="img/group-photo.jpg">
</section>
<body>
<section data-id="introduction">
</section>
<section data-id="members">
</section>
<section data-id="news">