Skip to content

Instantly share code, notes, and snippets.

View vparaskevas's full-sized avatar

Vasileios Paraskevas vparaskevas

View GitHub Profile
@arkanath
arkanath / Interval Partitioning Problem - Pseudocode
Last active July 12, 2018 17:58
Interval Partitioning Problem - Pseudocode
Problem: Given intervals with finish and end times, partition the intervals into labels with minimum amount of labels so that no two intervals in any label overlap.
Algorithm:
* Sort Intervals w.r.t. starting time, breaking tries arbitrarily.
* Let them be I1, I2, ... , In
* For j = 1:n
* For each (i<j && Ii,Ij overlap)
* Exclude the label of Ii from considering for Ij
* EndFor
@yoitsro
yoitsro / gist:8693021
Last active July 22, 2020 14:52
Node + Restify + Passport + Sessions + WebSockets
var restify = require('restify');
// Authentication
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var sessions = require("client-sessions");
var server = restify.createServer();
server.use(restify.queryParser());
server.use(restify.bodyParser());
@dominicsayers
dominicsayers / elasticsearch.md
Last active August 12, 2024 08:14
Configuring ElasticSearch to use less memory

What I actually did

/etc/security/limits.conf

elasticsearch hard memlock 100000

/etc/default/elasticsearch

@dzava
dzava / namedays.json
Created January 1, 2014 11:25
Greek name days.
[
[
[
"Βασίλειος",
"Βασίλης",
"Βάσος",
"Βασίλας",
"Βασιλάκης",
"Μπίλλης",
"Μπίλης",
@clayperez
clayperez / zebraRFID.js
Created November 22, 2013 01:27
ZEBRA COMMAND LINE RFID PRINT UTILITY Needs some cleanup work, but this handy script lets you execute simple print commands to a Zebra RFID printer that is connected to your computer.
///////////////////////////////////////
// RFID PRINTER COMMAND LINE UTILITY //
///////////////////////////////////////
// REQUIRES: node-printer by tojocky
// USAGE: node zebra.js <printer> <start> <end> <file.csv> <print/null>
//
// RANGE EXAMPLE prints range to screen only:
// C:> node zebra zebra 1 100
//
// RANGE EXAMPLE prints range:
@danwoods
danwoods / knapsack.js
Last active April 19, 2022 13:57
Knapsack algorithm in JavaScript
//Knapsack algorithm
//==================
// wikipedia: [Knapsack (0/1)](http://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_Knapsack_Problem)
// Given a set `[{weight:Number, benefit:Number}]` and a capacity,
// find the maximum value possible while keeping the weight below
// or equal to the capacity
// **params**:
// `capacity` : Number,
// `items` : [{w:Number, b:Number}]
// **returns**:
@ngryman
ngryman / parallel.js
Last active February 1, 2018 10:11
jQuery parallel script loading keeping execution order.
/**
* Load scripts in parallel keeping execution order.
* @param {array} An array of script urls. They will parsed in the order of the array.
* @returns {$.Deferred}
*/
function getScripts(scripts) {
var xhrs = scripts.map(function(url) {
return $.ajax({
url: url,
dataType: 'text',
@kadavre
kadavre / cake_email.php
Last active October 25, 2019 11:03
Send mail with cakephp using gmail.
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => '[email protected]',
'password' => 'motdepasse',
'transport' => 'Smtp',
'timeout' => 30
);
$email = new CakeEmail('gmail');
<?php
/**
* Presumes you've installed Composer in the directory according to http://getcomposer.org/doc/01-basic-usage.md
*/
require_once(APP . 'Vendor' . DS. 'LibPhoneNumber' . DS . 'src' . DS . 'libphonenumber'. DS ."PhoneNumberUtil.php");
require_once(APP . 'Vendor' . DS. 'LibPhoneNumber' . DS . 'src' . DS . 'libphonenumber'. DS ."CountryCodeToRegionCodeMap.php");
require_once(APP . 'Vendor' . DS. 'LibPhoneNumber' . DS . 'src' . DS . 'libphonenumber'. DS ."PhoneNumber.php");
require_once(APP . 'Vendor' . DS. 'LibPhoneNumber' . DS . 'src' . DS . 'libphonenumber'. DS ."data" . DS . "PhoneNumberMetadata_GB.php");
require_once(APP . 'Vendor' . DS. 'LibPhoneNumber' . DS . 'src' . DS . 'libphonenumber'. DS ."PhoneMetadata.php");
require_once(APP . 'Vendor' . DS. 'LibPhoneNumber' . DS . 'src' . DS . 'libphonenumber'. DS ."PhoneNumberDesc.php");
@RyanBrackett
RyanBrackett / jQuery.Responsive.Classes
Last active November 5, 2019 14:16
How About This...
/*
*
* Originally inspired by: http://designedbythomas.co.uk/blog/how-detect-width-web-browser-using-jquery
*
* Original source by https://gist.github.com/highrockmedia/3710930
*
* My contribution: I re-wrote some code it to fire as one function, so you're only editing values in one place.
*
*/