Skip to content

Instantly share code, notes, and snippets.

View jansabbe's full-sized avatar

jansabbe

View GitHub Profile
@jansabbe
jansabbe / test.js
Last active July 16, 2019 11:33
Sample signature generation
const crypto = require('crypto'); // Standard nodejs library. Tested using v10.15.0 and v8.11.4
const sparkcentralSecret = process.env['SECRET']; // shared secret as on settings
const expectedSignature = "1d051f7bfd06c7a3702788bb38bbb967109b5389c1f25af4909d0cb7d75d096d"; // take from request header.
const body = `
{
"email": "fj@example.com"
}
@jansabbe
jansabbe / withprofile
Last active April 23, 2018 19:55
JXA script for changing the current profile of the current tab in Terminal.app
#!/usr/bin/env osascript -l JavaScript
ObjC.import('stdlib')
function run(argv) {
const [newSettingSetName, ...commandArray] = argv;
const app = Application("Terminal");
const oldSettingsName = app.windows[0].selectedTab.currentSettings.name();
setSettingSet(app, newSettingSetName);
if (commandArray.length) {
@jansabbe
jansabbe / keyof.ts
Created June 29, 2017 20:42
Example of using keyof in typescript
function filter<T, K extends keyof T>(obj : T, keys : [K], value: any) : boolean {
return keys.some(key => obj[key] === value);
}
let person = {
name: "bos",
firstName: "jos"
}
filter(person, ['firstName', "namee"], "jos");
@jansabbe
jansabbe / GenericBuilder.cs
Last active June 29, 2020 05:50
Generic With method builder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Xunit;
namespace Tjoelala
{
public class Person
@jansabbe
jansabbe / GoogleTests.cs
Created May 18, 2017 12:20
Basic webdriver example with page objects
using System.Collections.Generic;
using System.Linq;
using HtmlElements;
using HtmlElements.Elements;
using HtmlElements.Extensions;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.PageObjects;
@jansabbe
jansabbe / gist:1f2acaebb353cd82b87b
Created July 10, 2015 09:07
Test builders in JavaScript using lodash
function createTestPerson(override) {
var defaultPerson = {
id: 1,
firstname: 'Bert',
lastname: 'Macklin'
}
return _.merge(defaultPerson, override);
}
var person1 = createTestPerson(),
let handler = {
get(target,name) {
return `Hello ${name}`
}
}
let obj = new Proxy({},handler);
obj.world // Hello world
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route("/api/users")
def users():
return jsonify(users = [
{
"firstname":"Joske",
"lastname": "Vermeulen"
@jansabbe
jansabbe / gist:1014701
Created June 8, 2011 15:55
sencha touch map with marker
new Ext.Map({
useCurrentLocation: true,
listeners: {
maprender : function(comp, map){
var marker = new google.maps.Marker({
position: map.center,
title : 'testing',
map: map
});
}
@jansabbe
jansabbe / gist:1011907
Created June 7, 2011 08:34
Get value of a parameter from a url in javascript
function getParameterByName(parameter, url) {
var parameterValue = RegExp("[?&]" + parameter + "=([^&]*)").exec(url);
return decodeURIComponent(parameterValue[1].replace(/\+/g, " "));
}