Skip to content

Instantly share code, notes, and snippets.

View AndresSepar's full-sized avatar
🤖
Coding mode!

Andres Separ AndresSepar

🤖
Coding mode!
View GitHub Profile
// package.json
{
"name": "dictionary",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@nrollr
nrollr / MongoDB_macOS_Sierra.md
Last active April 1, 2024 16:23
Install MongoDB on Sierra using Homebrew

Install MongoDB on macOS Sierra

This procedure explains how to install MongoDB using Homebrew on macOS Sierra 10.12.
Official MongoDB install documentation: here

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@Cosmicist
Cosmicist / scroller.js
Last active September 9, 2017 16:36 — forked from dezinezync/scroll.easing.js
Vanilla Javascript Scrolling function for easing based scrolling
var Scroller = function(anchors, config)
{
var cfg = compile({
duration: 1000,
offset: 0,
easing: Scroller.easing.inOutQuad,
callback: function() {}
}, config);
[].forEach.call(anchors, function(anchor) {
@DingGGu
DingGGu / stream.js
Last active March 26, 2024 06:13
NodeJS Mp3 Streaming ExpressJS
var express = require('express');
var app = express();
var fs = require('fs');
app.listen(3000, function() {
console.log("[NodeJS] Application Listening on Port 3000");
});
app.get('/api/play/:key', function(req, res) {
var key = req.params.key;
@msherstobitow
msherstobitow / google-maps-set-center-with-offset.js
Created September 23, 2014 13:43
How to offset the center of a Google maps (API v3) in pixels?
google.maps.Map.prototype.setCenterWithOffset= function(latlng, offsetX, offsetY) {
var map = this;
var ov = new google.maps.OverlayView();
ov.onAdd = function() {
var proj = this.getProjection();
var aPoint = proj.fromLatLngToContainerPixel(latlng);
aPoint.x = aPoint.x+offsetX;
aPoint.y = aPoint.y+offsetY;
map.setCenter(proj.fromContainerPixelToLatLng(aPoint));
};
@Nilpo
Nilpo / Autoloader.php
Last active August 25, 2023 18:41
A simple recursive PHP autoloader using the RecursiveDirectoryIterator.
<?php
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Rob Dunham
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@lovasoa
lovasoa / UTF8byteLength.js
Created April 27, 2014 23:23
Compute the length in bytes of a javascript string, when encoded in UTF8
function byteLength(str) {
// returns the byte length of an utf8 string
var s = str.length;
for (var i=str.length-1; i>=0; i--) {
var code = str.charCodeAt(i);
if (code > 0x7f && code <= 0x7ff) s++;
else if (code > 0x7ff && code <= 0xffff) s+=2;
if (code >= 0xDC00 && code <= 0xDFFF) i--; //trail surrogate
}
return s;
@rojan
rojan / node_crypto.js
Last active March 19, 2023 15:14
Encrypt in nodejs and decrypt in php or vice versa
var crypto = require('crypto');
var key = 'MySecretKey12345';
var iv = '1234567890123456';
var cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
var decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
var text = 'plain text';
var encrypted = cipher.update(text, 'utf8', 'binary');
encrypted += cipher.final('binary');
hexVal = new Buffer(encrypted, 'binary');
@lleo
lleo / html5-video-streamer.js
Last active September 2, 2020 13:42
This is an enhancement to Gist#1993068 https://gist.github.com/paolorossi/1993068 . I found what was needed to demonstrate a functioning video stream was a HTML file with a <video> tag pointing to the streamer.
#!/usr/bin/env node
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
* Modified from https://gist.github.com/paolorossi/1993068
*/
var http = require('http')
, fs = require('fs')
, util = require('util')
var departure = new google.maps.LatLng(-6.18049, 106.82638); //Set to whatever lat/lng you need for your departure location
var arrival = new google.maps.LatLng(-6.17770, 106.82141); //Set to whatever lat/lng you need for your arrival location
var line = new google.maps.Polyline({
path: [departure, departure],
strokeColor: "#FF0000",
strokeOpacity: 0.7,
strokeWeight: 2,
geodesic: true, //set to false if you want straight line instead of arc
map: map,
});