Skip to content

Instantly share code, notes, and snippets.

View scriptype's full-sized avatar
🍁

Mustafa Enes Ertarhanaci scriptype

🍁
View GitHub Profile
@scriptype
scriptype / Javascript Sudoku Puzzle Generator.markdown
Last active July 21, 2021 10:18
Javascript Sudoku Puzzle Generator

Javascript Sudoku Puzzle Generator

In this demo, backtracking algorithm is used for generating the sudoku. Difficulty and solvability is totally random as I randomly left a number of hints from a full-filled board.

A Pen by Mustafa Enes on CodePen.

License.

@scriptype
scriptype / index.js
Created November 7, 2015 16:03
Youtube /watch mapper
(function () {
'use strict'
var fs = require('fs')
var jsdom = require('jsdom')
var https = require('https')
// Prepare array of song objects
var list = fs.readFileSync('list.txt', 'utf8')
{
"patterns": [
{
"type": "path",
"term": "/some/path\\$/gi",
"transform": {
"path": "/some/other/path/file.x",
"name": "lorem",
"type": "jpeg"
}
{
"patterns": [
{
"type": "path",
"term": "/some/path\\$/gi",
"transform": {
"folderPath": "/some/other/path",
"name": "lorem",
"fileType": ".jpeg"
}
@scriptype
scriptype / Calculate PI digits.markdown
Last active March 20, 2016 19:23
Calculate PI digits (multiple workers)

Calculate PI digits

A little late to the party but here's a widget you can calculate as many digits of π as you want (actually, do not try with huge parameters).

Update: It's now working concurrently with as many workers as cpu cores. So it gets faster if your computer has more cpus.

A Pen by Mustafa Enes on CodePen.

License.

@scriptype
scriptype / Makefile
Last active June 6, 2016 09:55
Makefile for the front-end
BIN = ./node_modules/.bin
DIST = ./dist
SRC = ./src
HTML_INPUT = $(SRC)/index.html
HTML_OUTPUT = $(DIST)/index.html
CSS_INPUT_DIR = $(SRC)/stylesheets
CSS_INPUT = $(CSS_INPUT_DIR)/style.css
CSS_OUTPUT_MIN_DIR = $(DIST)
var t = e => atob(e.split(':').map(e => String.fromCharCode(parseInt(e,2))).join(''))
window[t('1011010:1101101:1010110:110000:1011001:110010:1100111:111101')](t('1100001:1001000:1010010:110000:1100011:1000100:1101111:1110110:1001100:110010:1001110:1110110:1011010:1000111:1010110:1110111:1011010:1010111:110100:1110101:1100001:1010111:111000:1110110:1100011:1000111:1000110:110010:1100010:1000111:111001:110010:1100011:110010:1110011:1110110:1100011:1000111:1010110:1110101:1001100:110001:1101000:1110100:1100001:1101100:1000010:1010000:1010010:1010001:111101:111101'), JSON.parse(t('1100101:1111001:1001010:1110100:1100010:110010:1010010:1101100:1001001:1101010:1101111:1101001:1100010:1101101:111000:1110100:1011001:110010:111001:1111001:1100011:1111001:1001010:111001')))
function EventEmitter(options) {
this._listeners = []
}
EventEmitter.prototype.on = function(event, handler) {
this._listeners[event] = this._listeners[event] || []
this._listeners[event].push(handler)
}
EventEmitter.prototype.off = function(event, handler) {
@scriptype
scriptype / app.js
Last active October 26, 2016 11:41
Single Page Application that doesn't depend on a framework
function EventEmitter(options) {
this._listeners = {}
}
EventEmitter.prototype.on = function(event, handler) {
this._listeners[event] = this._listeners[event] || []
this._listeners[event].push(handler)
}
EventEmitter.prototype.off = function(event, handler) {
@scriptype
scriptype / xor-pseudorandom-encryption.js
Last active November 18, 2016 18:26
Encryption with XOR and non-secure PRNG
function toBinary(plainText) {
return plainText.split('').map(c => {
return ('0'.repeat(BIT_COUNT) + c.charCodeAt(0).toString(2)).slice(-BIT_COUNT)
})
}
function generateKey(len) {
return ' '.repeat(len * BIT_COUNT).split('').reduce(p => p + ~~(Math.random() * 2), '')
}