Skip to content

Instantly share code, notes, and snippets.

View Somrlik's full-sized avatar
🏳️
Uncaught ReferenceError: status is not defined

Somrlik

🏳️
Uncaught ReferenceError: status is not defined
View GitHub Profile
@Somrlik
Somrlik / mandelbrot_666.js
Created April 2, 2020 11:09
mandelbrot_666.js
((m,a,n,d,e,l,b,r,o,t)=>{var s=m.createElement("canvas");t.style.margin="0",t.prepend(s),s.style.width="100vw",s.style.height="100vh",t.style.overflow="hidden";var _=s.getContext("2d"),w=t=>{let e=t[0],n=t[1];for(var i=0;i<125;i++){var h=e*e-n*n+t[0],l=2*e*n+t[1];if((e=h)*(n=l)>5)return i/125*100}return 0},f=()=>{s.width=s.clientWidth,s.height=s.clientHeight;var t=48.61/(Math.log(s.width)+5.67)+210,e=s.width/2*1.15,n=s.height/2*.9;for(let i=0;i<s.width;i++)for(let h=0;h<s.height;h++){var l=w([(i-e)/t,(h-n)/t]);_.fillStyle=0===l?"#000":`hsl(0, 100%, ${l}%)`,_.fillRect(i,h,1,1)}};f(),window.addEventListener("resize",f)})(document,0,0,0,0,0,0,0,0,document.body)
((m, a, n, d, e, l, b, r, o, t, _?: any) => {
_ = m.createElement(n), t.style.margin = r, t.append(_), _.style.width = e, _.style.height = d, t.style.overflow = o;
const ctx = _.getContext(l);
const p = (pos: [number, number]): number => {
let rcr = pos[0], icr = pos[1];
for(var i = 0; i < b; i++) {
const trc = (rcr * rcr - icr * icr + pos[0]), tic = (2 * rcr * icr + pos[1]);
rcr = trc, icr = tic;
if(rcr * icr > 5) return (i / b * 100);
#!/usr/bin/env bash
MYSQL_DATABASE="db_name"
MYSQL_USER="root"
MYSQL_PASS="root"
MYSQL_HOST="127.0.0.1"
TMP_FILENAME="/tmp/tmp.sql"
echo "SET FOREIGN_KEY_CHECKS = 0;" > ${TMP_FILENAME}
@Somrlik
Somrlik / convert-books.js
Created March 12, 2020 00:12
Convert ebooks using calibri CLI
#!/usr/bin/env node
/*
* Converts e-books using calibri convert-ebook binary to files well readable on ipad/any tablet
*
* Libs required can be installed by running `yarn add glob async yargs`
*
* Requires node >= 10 I guess.
*/
@Somrlik
Somrlik / clean-git.sh
Created January 3, 2019 09:04
I copied this gist from somewhere, but forgot where, so I am putting it here
#!/usr/bin/env bash
# This has to be run from master
git checkout master
# Update our list of remotes
git fetch
git remote prune origin
# Remove local fully merged branches

SiDeSeG - Simple development SSL certificate generator

This is a simple utility. Do not ever use this to generate anything going live!

I am a small utility hacked together in Python in about 3 hours, suitable for creation of development certificates, if you want to use service workers or test out http/2 features locally.

@Somrlik
Somrlik / converting-everything-to-utf8mb4.sql
Created November 3, 2017 01:29
A sql query that will create sql commands to convert all tables and columns from database to utf8mb4 so you can have emojis in text you sicko
SELECT CONCAT(
'ALTER TABLE ',TABLE_SCHEMA,'.',TABLE_NAME,
' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;'
)
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'databasename';

Setting up a nice php dev on localhost

This guide was written mainly for myself, as not to forget all the little things and not google all the answers again. But of course anyone can use the guide to get a few pointers and ideas to improve their local developement stack. Note that most of the commands here have to be run with elevated permissions, so I omitted writing sudo of # in front of everything.

I am of course not responsible for breaking your system. Make sure you understand what you are doing, common sense etc.

DNS resolving for different .dev/.test domains

When working on multiple projects at once, it is often practical to not have them all on the same domain. Entering localhost/foo or localhost/bar to switch can work, but sometimes integrations with frontend can lead to problems with relative paths. Sometimes you also need to parse domain names and/or paths and as most of your applications will run in the webroot I found it easier to just write foo.dev or bar.dev into the addre

@Somrlik
Somrlik / FuckThisHorrifyingSyntax.sh
Created July 23, 2017 21:36
Find and copy file tree modified in last two weeks
find . -type f -mtime -14 -exec cp --parents \{\} updated-files/ \;