Skip to content

Instantly share code, notes, and snippets.

@jeantimex
jeantimex / express-static-server-cros.js
Last active February 21, 2021 20:50
Express server with Cross-Origin-Opener-Policy
const express = require('express');
const app = express();
// Setting up the public directory
app.use(express.static('public', {
setHeaders: (res) => {
res.set('Cross-Origin-Opener-Policy', 'same-origin');
res.set('Cross-Origin-Embedder-Policy', 'require-corp');
}
}));
@jeantimex
jeantimex / gl-boilerplate.js
Created February 15, 2021 04:39 — forked from migurski/gl-boilerplate.js
WebGL GeoJSON tile rendering II
function linkProgram(gl, vsource, fsource)
{
if(gl == undefined)
{
alert("Your browser does not support WebGL, try Google Chrome? Sorry.");
throw "Your browser does not support WebGL, try Google Chrome? Sorry.";
}
var program = gl.createProgram(),
vshader = createShader(gl, vsource, gl.VERTEX_SHADER),
/*
Common vector operations
Author: Tudor Nita | cgrats.com
Version: 0.51
*/
function Vec2(x_,y_)
{
this.x = x_;
this.y = y_;
@jeantimex
jeantimex / parse-options.sh
Created July 31, 2020 01:57 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@jeantimex
jeantimex / Vector2D.js
Created July 29, 2020 07:11
JavaScript 2D Vector Class
/*
Simple 2D JavaScript Vector Class
Hacked from evanw's lightgl.js
https://github.com/evanw/lightgl.js/blob/master/src/vector.js
*/
function Vector(x, y) {
@jeantimex
jeantimex / iPod.swift
Created July 28, 2020 04:49 — forked from jordansinger/iPod.swift
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}

From https://www.silentorbit.com/notes/2013/rsync-by-extension/

Having a file structure full of various file types you want to sync only files of one type into a new location.

rsync -rv --include '*/' --include '*.js' --exclude '*' --prune-empty-dirs Source/ Target/

This will generate the same structure found in Source into Target but only including the JavaScript(.js) files.

@jeantimex
jeantimex / webpack.config.js
Created June 19, 2020 15:08 — forked from ayastreb/webpack.config.js
Build Chrome Extension with React using Webpack
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
// Entry files for our popup and background pages
entry: {
popup: './src/popup.js',
@jeantimex
jeantimex / background.js
Created June 10, 2020 06:58
Simple Chrome extension
var toggle = false;
chrome.browserAction.onClicked.addListener(function (tab) {
toggle = !toggle;
if (toggle){
// chrome.browserAction.setIcon({path: "on.png", tabId:tab.id});
chrome.tabs.executeScript(tab.id, {file: "color-picker.js"});
} else {
//chrome.browserAction.setIcon({path: "off.png", tabId:tab.id});
//chrome.tabs.executeScript(tab.id, {code: "alert('hello')"});
const express = require('express');
const app = express();
app.use(express.static('public'));
app.get('/', (req, res) => {
res.send('An alligator approaches!');
});
app.listen(3000, () => console.log('Gator app listening on port 3000!'));