Skip to content

Instantly share code, notes, and snippets.

View ewized's full-sized avatar

ewized

View GitHub Profile
const red = (text) => ({ color: '31', text })
const green = (text) => ({ color: '32', text })
const white = (text) => ({ color: '0', text })
const color = (strings, ...args) => {
const colorize = args.map(({ color, text }) => `\x1b[${color}m${text}`)
return strings.reduce((acc, item) => `${acc}${item}${colorize.shift() ?? ''}`, '')
}
console.log(color`${red`FAIL`} ${white`foobar`} ${green`pass`}`)
@ewized
ewized / cors-anywhere-import.js
Last active December 1, 2019 15:22
Script that will install base_elements from the latest release version
'use strict'
// Import the script from the url
function importScript(url) {
const request = new XMLHttpRequest()
request.onload = () => eval(request.responseText)
request.open('GET', url, true)
request.send()
}
<!DOCTYPE html>
<html>
<head>
<style>
.dot {
position: absolute;
height: 10px;
width: 10px;
display: block;
background: #000;
@ewized
ewized / fix_id_conflict.sql
Last active February 8, 2018 01:41
Postgres Bug Fix ID Conflict
-- What we did to fix this bug,
-- https://hcmc.uvic.ca/blogs/index.php?blog=22&p=8105&more=1&c=1&tb=1&pb=1
--SELECT MAX(id) FROM pilot;
--SELECT nextval('public.pilot_id_seq');
--SELECT pg_get_serial_sequence('pilot', 'id')
--SELECT nextval('public.pilot_id_seq');
--SELECT setval('public.pilot_id_seq', 13833);
<settings>
<profiles>
<profile>
<id>projectares</id>
<repositories>
<repository>
<id>freundtech</id>
<name>freundTech</name>
<url>https://repo.freundTech.com</url>
</repository>
@ewized
ewized / links.txt
Created September 26, 2016 03:41
Pictures from Addons/Plugin panel
@ewized
ewized / bootstrap.py
Last active August 30, 2016 22:59
Ansible bootstrap script that sets up the requirements to run a remote playbook
# This python script is a lightweight script that ensures that the proper
# packages are installed on the remote host, must have hostname defined
# $ hostname new-host ; wget -O - goo.gl/G3JWa4 | python
import os
import sys
print('-' * 5 + ' [Ansible Bootstrap Script] ' + '-' * 5)
print("echo")
@ewized
ewized / generate_types.py
Created May 10, 2016 17:43
This file will generate the packet types from the wiki.vg website
#!/usr/bin/python3
# Copyright 2016 Year4000. All Rights Reserved.
from urllib.request import urlopen
from xml.etree.ElementTree import fromstring
import re
def set_up():
""" Ask the user for the url and file name """
# protocol
@ewized
ewized / BeforeAfter.java
Created May 3, 2016 16:54
Before and After - Shows how R/D code becomes clean Production code
// AFTER
public static Class<?>[] after(String str) throws Exception {
Conditions.nonNull(str, "str");
str = str.substring(1, str.lastIndexOf(")"));
List<Class<?>> args = Lists.newArrayList();
for (int i = 0 ; i < str.length(); i++) {
int a = i;
if (str.charAt(i) == '[') { // Process arrays
while (str.charAt(a) == '[' && i < str.length()) {