Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Parent Bust Example</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; }
#countdown { font-size: 2em; color: #559; margin-bottom: 20px; }
#bustBtn { padding: 10px 20px; font-size: 1em; }
</style>
import {connector, config, graph} from "@grafbase/sdk"
const g = graph.Standalone()
const mongo = connector.MongoDB("Human", {
url: g.env("MONGODB_API_URL"),
apiKey: g.env("MONGODB_API_KEY"),
dataSource: g.env("MONGODB_DATASOURCE"),
database: g.env("MONGODB_DATABASE"),
})
@sultano
sultano / generate-codes.php
Created November 1, 2022 13:32
Generate random codes
<?php
$nbVouchers = 100;
if (isset($argv[1]) && is_numeric($argv[1])) {
$nbVouchers = (int)$argv[1];
}
function generateVoucherCode($len = 5, $alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ') {
$str = '';
$found = 0;
@sultano
sultano / ecdh_iocane.js
Created June 7, 2017 10:02 — forked from perry-mitchell/ecdh_iocane.js
ECDH key exchange with AES encryption using iocane
// To use this, you will need to `npm install iocane`!
const crypto = require("crypto");
let aliceECDH = crypto.createECDH("secp256k1");
aliceECDH.generateKeys();
let alicePublicKey = aliceECDH.getPublicKey(null, "compressed"),
alicePrivateKey = aliceECDH.getPrivateKey(null, "compressed");
@sultano
sultano / nodejs-tcp-example.js
Created May 29, 2017 10:44 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@sultano
sultano / chatServer.js
Created May 29, 2017 09:48 — forked from creationix/chatServer.js
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@sultano
sultano / gulpfile.js
Created November 6, 2016 13:03 — forked from gregberge/gulpfile.js
Watchify, browserify gulp.
var gulp = require('gulp');
var gutil = require('gulp-util');
var watchify = require('watchify');
var uglify = require('gulp-uglify');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var browserSync = require('browser-sync');
var sass = require('gulp-ruby-sass');
var filter = require('gulp-filter');
@sultano
sultano / package.json
Created November 4, 2016 17:35 — forked from andreruffert/package.json
using `npm run` to build and watch with node-sass and browserify
{
"name": "my-app",
"version": "0.0.0",
"devDependencies": {
"browserify": "^10.2.4",
"watchify": "^3.2.3",
"node-sass": "^3.2.0",
"uglify": "^2.4.23",
"mkdirp": "^0.5.1",
"parallelshell": "^1.2.0",