Skip to content

Instantly share code, notes, and snippets.

@snakeneedy
snakeneedy / gridCalculator.scss
Created May 25, 2020 10:08
Grid calculator for SCSS.
$maxGridWidth: 1280px;
$marginWidth: 8px;
$gutterWidth: 16px;
$numMaxColumns: 16;
$singleColumnWidth: ($maxGridWidth - $marginWidth * 2 - $gutterWidth * ($numMaxColumns - 1)) / $numMaxColumns;
@function calColumnWidth($numColumns) {
@if $numColumns <= 0 {
@return 0px;
}
@snakeneedy
snakeneedy / typeUtil.js
Created May 21, 2020 05:22
Type utility in JS.
const getTypeName = (o) => {
if (o === undefined) return 'undefined';
if (o === null) return 'null';
return o.constructor.name;
};
const isUndefined = (o) => (o === undefined);
const isNull = (o) => (o === null);
@snakeneedy
snakeneedy / getUniqueTimstampAsync.js
Created May 21, 2020 04:03
Get unique timestamp as number in JavaScript.
const sleepAsync = (ms) => (new Promise((resolve) => (setTimeout(resolve, ms))));
const getUniqueTimstampAsync = (function () {
let prev;
return async function () {
let timestamp = +(new Date());
while (prev === timestamp) {
await sleepAsync(1);
timestamp = +(new Date());
}
VERSION=v10.15.3
DIST=linux-x64
# Step 2: install NodeJS and npm
wget https://nodejs.org/dist/$VERSION/node-$VERSION-$DIST.tar.xz
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DIST.tar.xz -C /usr/local/lib/nodejs
sudo mv \
/usr/local/lib/nodejs/node-$VERSION-$DIST \
/usr/local/lib/nodejs/node-$VERSION
@snakeneedy
snakeneedy / htmlcomplete.vim
Last active June 28, 2018 15:06
VIM script in /usr/share/vim/vim81/autoload/, fix lowercase omni autocompletion (see Revisions)
" Vim completion script
" Language: HTML and XHTML
" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
" Last Change: 2014 Jun 20
" Distinguish between HTML versions.
" To use with other HTML versions add another "elseif" condition to match
" proper DOCTYPE.
function! htmlcomplete#DetectOmniFlavor()
if &filetype == 'xhtml'
@snakeneedy
snakeneedy / py3-class-method.py
Created June 24, 2018 06:29
Python 3: sample of class methods
"""Result:
call self_method by Inst
---
call self_method by Temp
---
call class_method by Inst
call self_method by class_method
---
call class_method by Temp
@snakeneedy
snakeneedy / meta-tags.md
Created June 2, 2018 07:52 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@snakeneedy
snakeneedy / AoE2CheatsRobot.java
Created August 5, 2017 02:17
世紀帝國二資源作弊碼程式,四種資源各五萬(可修改),在「交談」畫面使用
import static java.awt.event.KeyEvent.*;
import java.awt.*;
public class AoE2CheatsRobot {
private Robot robot;
public static void main(String... args) throws Exception {
AoE2CheatsRobot keyboard = new AoE2CheatsRobot();
keyboard.wait(5000); // wait 5000 ms
@snakeneedy
snakeneedy / lab01.s
Created March 7, 2017 11:48
$t0 = 1 + 2 + ... + 25
.text
.globl main
main:
sub $t0, $t0, $t0
addi $t1, $0, 1
For:
add $t0, $t0, $t1
addi $t1, $t1, 1
beq $t1, 26, exit
b For
@snakeneedy
snakeneedy / example.desktop
Last active November 21, 2016 16:29
This is an example of Ubuntu desktop.
[Desktop Entry]
Version=1.0
Type=Link
Name=Examples
Name[aa]=Ceelallo
Name[ace]=Contoh
Name[af]=Voorbeelde
Name[am]=ምሳሌዎች
Name[an]=Exemplos
Name[ar]=أمثلة