Skip to content

Instantly share code, notes, and snippets.

@hamzamu
hamzamu / server.sh
Created March 16, 2020 18:08
Meteor deployment script
#!/bin/bash
#============================
#
#
# Meteor Deployment Script
#
# Require Installtion of pm2
#
#============================
Project_name=
@hamzamu
hamzamu / map.swiss.js
Created March 16, 2020 14:55
Map D3 JSON
// http://bl.ocks.org/herrstucki/4327678
var width = 960,
height = 500;
var path = d3.geo.path()
.projection(null);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("/swiss/ch.json", function (error, ch) {
http://feeds.reuters.com/news/artsculture
http://feeds.reuters.com/reuters/businessNews
http://feeds.reuters.com/reuters/companyNews
http://feeds.reuters.com/reuters/entertainment
http://feeds.reuters.com/reuters/environment
http://feeds.reuters.com/reuters/healthNews
http://feeds.reuters.com/reuters/lifestyle
http://feeds.reuters.com/news/reutersmedia
http://feeds.reuters.com/news/wealth
http://feeds.reuters.com/reuters/MostRead
@hamzamu
hamzamu / slugify.js
Created January 25, 2020 09:15 — forked from codeguy/slugify.js
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@hamzamu
hamzamu / slugify.js
Created January 25, 2020 09:15 — forked from codeguy/slugify.js
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@hamzamu
hamzamu / vign1.red
Created January 3, 2020 12:36 — forked from kermitaner/vign1.red
vigenere encrypting with gui
Red [needs: 'view]
CRLF: copy "^M^/" ;; constant for 0D 0A line feed
;;------------------------------------
crypt: func ["function to en- or decrypt message from textarea tx1"
/decrypt "decrypting switch/refinement" ][
;;------------------------------------
;; when decrypting we have to remove the superflous newlines
;; and undo the base64 encoding first ...
@hamzamu
hamzamu / server.js
Last active January 1, 2020 02:09
Meteor Promise: Await
// https://blog.meteor.com/using-promises-and-async-await-in-meteor-8f6f4a04f998
import { Promise } from 'meteor/promise';
async function run(command) {
log('Running: ', command);
return execSync(command).toString().trim();
}
@hamzamu
hamzamu / shell-command.red
Created December 23, 2019 21:28
Red: Execute external and shell command
http://www.red-by-example.org/#call
The word call executes a shell command to run another process.
The argument is:
A command [string! file!] - A shell command or an executable file.
Refinements
/wait - Runs command and waits for exit.
@hamzamu
hamzamu / main.server.js
Last active December 23, 2019 20:43
Meteor: Set Env Paramter
import { Meteor } from 'meteor/meteor';
log = console.log
Meteor.startup(() => {
// code to run on server at startup
process.env.ROOT_URL = 'http://localhost';
process.env.PORT = 3333
log('Running at http://localhost:3333')
});
@hamzamu
hamzamu / html-generate.red
Last active November 22, 2019 16:53
HTML. generator [Red]
Red [
Title: Simple HTML Generation Test
]
data: [
title: "This is the title"
content: "This is a content block"
]
html: {
<HTML>