Skip to content

Instantly share code, notes, and snippets.

Sven Slootweg joepie91

Block or report user

Report or block joepie91

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joepie91
joepie91 / .js
Last active Aug 26, 2015 — forked from dsauerbrun/.js
View .js
function buildTranslations(message, originLanguage, destLanguages){
return Promise.try(function(){
translations = {};
destLanguages.map(function(currentLang){
translations[currentLang.code] = {}
db.model('Translation').translate(message,originLanguage.code,currentLang.code).then(function(translation){
console.log('build Trans function'+translation);
translations[currentLang.code] = translation;
});
});
@joepie91
joepie91 / .js
Last active Aug 27, 2015 — forked from dsauerbrun/.js
View .js
function bingTranslate(message,originLang,destLang,accessToken){
Promise.try(function(){
accessToken.then(function(bingToken){
options = {
headers:{
'Authorization': "Bearer "+accessToken
}
};
queryString="text="+encodeURIComponent(message)+"&from="+originLang+"&to="+destLang+"&contentType=text%2Fplain";
return bhttp.get("http://api.microsofttranslator.com/V2/Http.svc/Translate?"+queryString,options).then(function(data){
View converted.md
---
layout: post
title: "How to write proper PHP"
permalink: 2013/12/17/how-to-write-proper-php
postday: 2013/12/17
posttime: 05_57
tags: untagged
---
View gist:1021886303cc22200e9c
// models/user.js
module.exports = function(bookshelf) {
return bookshelf.define(/* blah blah blah */);
}
// app.js
var bookshelf = /* connection stuff goes here */
var User = require("models/user")(bookshelf)
@joepie91
joepie91 / gist:214be25a73df86cfd2f8
Created Jun 26, 2014
Generic gulpfile for Node.js (npm) packages
View gist:214be25a73df86cfd2f8
/* npm install --save-dev gulp gulp-util gulp-concat gulp-rename gulp-coffee gulp-cached gulp-remember gulp-plumber */
var gulp = require('gulp');
/* CoffeeScript compile deps */
var path = require('path');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var coffee = require('gulp-coffee');
@joepie91
joepie91 / gist:7c0dab92f64e192d2691
Last active Aug 29, 2015
AnonNews scoring algo
View gist:7c0dab92f64e192d2691
frontpageScore = (upvotes, minutes) ->
maxMinutes = (48 * 60);
maxMultiplier = Math.pow(1.001, maxMinutes);
if minutes > maxMinutes
minutes = maxMinutes
factor = 1 - (Math.pow(1.001, minutes) / maxMultiplier)
return factor * upvotes
@joepie91
joepie91 / gulpfile.js
Last active Aug 29, 2015
Gulpfile for Express + CoffeeScript + Theseus + Nodemon + LiveReload
View gulpfile.js
var gulp = require('gulp');
var path = require('path');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var coffee = require('gulp-coffee');
var cache = require('gulp-cached');
var remember = require('gulp-remember');
var plumber = require('gulp-plumber');
View util.coffee
S = require "string"
Promise = require "bluebird"
request = require "request"
libxml = require "libxmljs"
longest = require "longest"
module.exports =
createTeaser: (input, length) ->
if input.length > length
re = new RegExp("^((.|[\r\n]){0,#{length}})(\\W|$)", "")
@joepie91
joepie91 / util.coffee
Last active Aug 29, 2015
Newer AnonNews stuff
View util.coffee
S = require "string"
Promise = require "bluebird"
request = require "request"
libxml = require "libxmljs"
longest = require "longest"
cld = Promise.promisifyAll(require "cld")
urlLib = require "url"
module.exports =
createTeaser: (input, length) ->
@joepie91
joepie91 / proxy.coffee
Last active Aug 29, 2015
AnonNews Image Proxy
View proxy.coffee
Promise = require "bluebird"
express = require "express"
router = express.Router()
gm = require "gm"
util = require "../util"
fs = require "fs"
path = require "path"
moment = require "moment"
request = require "request"
urlLib = require "url"
You can’t perform that action at this time.