Skip to content

Instantly share code, notes, and snippets.

View tralamazza's full-sized avatar

Daniel Tralamazza tralamazza

View GitHub Profile
// @see https://www.avespeak.com/index.php?title=Choocher
object APIChoocher {
const val BASE_URL = "https://jsonplaceholder.typicode.com"
suspend fun posts(): JSONObject = request("api/posts")
suspend fun post(id: String): JSONObject = request("api/posts/$id")
suspend fun postCreate(title: String, body: String, userId: Int): JSONObject =
request("api/posts", Request.Method.POST, JSONObject(mapOf("title" to title, "body" to body, "userId" to userId)))
/**
package io.matchx.lpwancontroller.api
import android.app.IntentService
import android.content.Intent
import android.support.v4.content.LocalBroadcastManager
import java.io.DataInputStream
import java.io.File
import java.io.FileOutputStream
import java.net.URL
const express = require('express')
const bodyParser = require('body-parser')
const jwt = require('jsonwebtoken')
const mongoose = require('mongoose')
const User = require('./models/user')
mongoose.Promise = global.Promise
mongoose.connect('mongodb://localhost/mock_server', { useMongoClient: true });
const app = express()
mixer custom
mmix reset
mmix 0 1 -1 0.796 -1
mmix 1 1 -1 -0.796 1
mmix 2 1 1 0.796 1
mmix 3 1 1 -0.796 -1
#!/bin/bash
if [[ "$#" -lt 1 ]];
then
echo "Usage: $0 certificate-name [certs subfolder]"
exit 1
fi
NAME=$1
import CoreData
extension NSManagedObject {
convenience public init(insertInto context: NSManagedObjectContext?) {
let name = String(describing: type(of: self))
let entity = NSEntityDescription.entity(forEntityName: name, in: context!)
self.init(entity: entity!, insertInto: context)
}
}
@tralamazza
tralamazza / erlang
Created December 5, 2016 14:13
edelivery fix
status "Generating release"
__sync_remote "
[ -f ~/.profile ] && source ~/.profile
set -e
cd $DELIVER_TO
if [ \"$RELEASE_CMD\" = \"rebar\" ]; then
echo \"using rebar to generate release\"
$REBAR_CMD $RELEASE_CMD_OPTIONS -f generate
@tralamazza
tralamazza / custom_err.js
Created September 29, 2016 15:05
node 6 custom error
class CustomError extends Error {
constructor(message) {
super(message); // also sets .message
this.name = this.constructor.name; // and not 'Error'
Error.captureStackTrace(this, this.constructor); // remove ctor from the stacktrace
}
}
module.exports = CustomError;
@tralamazza
tralamazza / how-to-wireshark-ble.md
Last active August 25, 2017 16:30
[How-to] wireshark nordic BTLE plugin

sniffer firmware

  • Download and extract the latest Sniffer firmware

  • Flash the .hex file found in the /Firmware:

      $> JLinkExe -if SWD -device nrf51
      h
      w4 0x4001e504, 0x2
      w4 0x4001e50c, 0x1
    

loadbin ble-sniffer_nRF51822_1.0.1_1111_Sniffer.hex, 0

@tralamazza
tralamazza / fi.sh
Last active May 31, 2016 11:04
opening low ports
sudo setcap CAP_NET_BIND_SERVICE=+eip <path to your binary>