Skip to content

Instantly share code, notes, and snippets.

View bozdoz's full-sized avatar
☠️
I may be dead

bozdoz bozdoz

☠️
I may be dead
View GitHub Profile
@Mamboleoo
Mamboleoo / script.js
Last active April 23, 2021 22:04
Dot along a sphere [3D-2D]
const DOT_RADIUS = 10; // Radius of the dots
let GLOBE_RADIUS = width / 3; // Radius of the globe based on the canvas width
class Dot {
constructor() {
this.theta = Math.random() * 2 * Math.PI; // Random value between [0, 2Pi]
this.phi = Math.acos((Math.random() * 2) - 1); // Random value between [0, Pi]
// The x, y, z coordinates will be calculated in the project() function
this.x = 0;
@Mamboleoo
Mamboleoo / script.js
Last active April 23, 2021 21:51
Dot class [2D-3D]
let PERSPECTIVE = width * 0.8; // The field of view of our 3D scene
let PROJECTION_CENTER_X = width / 2; // x center of the canvas
let PROJECTION_CENTER_Y = height / 2; // y center of the canvas
const dots = []; // Store every particle in this array
class Dot {
constructor() {
this.x = (Math.random() - 0.5) * width; // Give a random x position
this.y = (Math.random() - 0.5) * height; // Give a random y position
this.z = Math.random() * width; // Give a random z position
@Hotell
Hotell / cra-2-ts-css-modules-guide.md
Last active March 25, 2022 16:07
typed css-modules - CRA 2.0

CRA 2.x + TS setup:

This will give you complete intellisense and type safety within your app and CSS modules

typesafe-css-modules

🚨 NOTE

  • refactoring className from ts file wont update your css/scss className, to change class names you have to change it within your .module.scss file
@Tamal
Tamal / git-ssh-error-fix.sh
Last active July 8, 2024 13:24
Solution for 'ssh: connect to host github.com port 22: Connection timed out' error
$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
$ # This should also timeout
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
$ # but this might work
@bxcodec
bxcodec / priority_queue.go
Created April 13, 2018 10:27
Golang Priority Queue
package main
import (
"container/heap"
"fmt"
)
type Item struct {
Name string
Expiry int
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@khamiltonuk
khamiltonuk / specificTimeCheck.js
Last active October 30, 2019 15:19
Optimising JavaScript performances with asynchronous loops
function splitLoop(items, process, context, callback) {
var todo = items.concat();
setTimeout(function () {
var start = +new Date();
do {
process.call(context, todo.shift());
} while (todo.length > 0 && (+new Date() - start < 50));
@andrewflash
andrewflash / php_mailer.php
Created November 23, 2013 05:32
Using PHP Mailer to Send HTML Emails with Images
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->SMTPAuth = true;
$mail->Username = 'smtpusername';
$mail->Password = 'smtppassword';
$mail->From="mailer@example.com";
@alexjs
alexjs / cors-nginx.conf
Created November 28, 2012 22:42 — forked from michiel/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@joshkersey
joshkersey / wordpress_setup.sh
Created May 15, 2012 17:25
WordPress setup Bash script
#!/bin/bash
# Installation script for a Wordpress 3.0 website on Ubuntu 10.04
#
# Josh Kersey
# Created: May 15, 2012
# Last Update: June 13, 2012
# get setup parameters
echo "apache vhost name (one word):"