Skip to content

Instantly share code, notes, and snippets.

@vrachieru
vrachieru / merge-overlapping-intervals.js
Created October 5, 2014 21:26
Merge overlapping intervals
/* Merge overlapping intervals
*
* Example:
* [[1,4],[3,5],[2,4],[7,10]] -> [[1,5],[7,10]]
*/
function mergeIntervals(intervals) {
// test if there are at least 2 intervals
if(intervals.length <= 1)
return intervals;
# Basic Strongswan ikev2 server setup
* paltform: atlantic.net ubuntu 14.04 x64
* the commands below are run with root account
## Strongswan
```
apt-get install strongswan
apt-get install iptables iptables-persistent
```
@EleotleCram
EleotleCram / aprintf
Last active April 16, 2023 05:14
Simple arduino formatted printf
int aprintf(char *str, ...) {
int i, j, count = 0;
va_list argv;
va_start(argv, str);
for(i = 0, j = 0; str[i] != '\0'; i++) {
if (str[i] == '%') {
count++;
Serial.write(reinterpret_cast<const uint8_t*>(str+j), i-j);
@hertzg
hertzg / cc-node-armv6hf.sh
Last active June 17, 2021 01:54
Cross Compiling NodeJS for Raspberry PI (armv6hf)
#!/bin/bash
set -e
set -x
### IF we dont have archive url prefix
if [ -z "$_PARAMS_NODEJS_SOURCE_ARCHIVE_URL" ]; then
_PARAMS_NODEJS_SOURCE_ARCHIVE_URL=$(wget -qO- http://nodejs.org/dist/latest/ | egrep -o 'node-v[0-9\.]+.tar.gz' | tail -1);
_PARAMS_NODEJS_SOURCE_ARCHIVE_URL="http://nodejs.org/dist/latest/"$_PARAMS_NODEJS_SOURCE_ARCHIVE_URL
fi
@rnorth
rnorth / bc
Last active August 3, 2016 00:49
Boxcar push notification shell script
#!/bin/bash
# Sends a Boxcar push notification through the Boxcar HTTP API
# Usage examples
# $ bc # Just sends a notification with title 'bc'
# $ bc "Done" # Sends a notification with title 'Done'
# $ echo foobar | bc # Sends a notification with title 'bc' and message body 'foobar'
# $ echo foobar | bc "Done" # Sends a notification with title 'Done' and message body 'foobar'
#
# Expects a file ~/.boxcar to exist with content like
@agendor
agendor / hapijs-rest-api-tutorial.md
Last active August 31, 2021 08:31
A practical introduction to building a RESTful API with the hapi.js server framework for Node.js
@szepeviktor
szepeviktor / nginx-chroot-helper.sh
Last active August 10, 2016 10:51
nginx Chroot Helper Script To Copy Libs To /lib64 and /usr/lib64
#!/bin/bash
set -e
# Use this script to copy shared (libs) files to nginx chrooted
# jail server. This is tested on 64 bit Linux (Redhat and Friends only)
# ----------------------------------------------------------------------------
# Original Written by Vivek Gite <http://www.cyberciti.biz/>
# (c) 2006 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# See url for usage:
@d2rk
d2rk / pi_speech_recognition.sh
Created February 23, 2014 12:16
Speech recognition with Raspberry Pi and Google Speech API
#!/bin/bash
echo "Recording, press ctrl+c to stop..."
arecord -D "plughw:1,0" -q -f cd -t wav | ffmpeg -loglevel panic -y -i - -ar 16000 -acodec flac speech.flac > /dev/null 2>&1
echo "Processing..."
wget -q -U "Mozilla/5.0" --post-file speech.flac --header "Content-Type: audio/x-flac; rate=16000" -O - "http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium" | cut -d\" -f12 > speech.txt
echo -n "You said: "
cat speech.txt
@lossendae
lossendae / index.html
Last active July 4, 2019 20:22
Dynamic (single level) menu for Angular ui-router
<!DOCTYPE html>
<html ng-app>
<head>
<title>Example</title>
</head>
<body>
<nav class="main-nav" data-main-menu data-root="index"></nav>
<script type="text/javascript" src="angular.js"></script>

Title: Настройка сервера VPN L2TP/IPSec на Mikrotik RoutersOS Date: 2013-05-31 17:25 Category: Mikrotik Tags: mikrotik, vpn Slug: mikrotik-lt2p-vpn Summary: Краткое описание настройки сервера VPN L2TP/IPSec на Mikrotik RoutersOS c возможностью подключения с помощью встроенных VPN клиентов Windows 7, Mac OS X и IOS.

Alt Text

Замечение: Если несколько клиентов находятся за NAT, то только одно L2TP/IPSec соединение может быть установлено.