Skip to content

Instantly share code, notes, and snippets.

@previtus
previtus / client.py
Created February 10, 2018 03:23
running keras/tensorflow on different machine server with local client
import requests
from timeit import default_timer as timer
PORT = "9999"
PRED_KERAS_REST_API_URL = "http://localhost:"+PORT+"/predict"
TIME_KERAS_REST_API_URL = "http://localhost:"+PORT+"/time"
IMAGE_PATH = "small.jpg"
# load the input image and construct the payload for the request
image = open(IMAGE_PATH, "rb").read()
@WalternativE
WalternativE / compute-sha-256-hash.ps1
Created March 28, 2017 07:18
Powershell script that returns SHA-256 hash for a given string
Param (
[Parameter(Mandatory=$true)]
[string]
$ClearString
)
$hasher = [System.Security.Cryptography.HashAlgorithm]::Create('sha256')
$hash = $hasher.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($ClearString))
$hashString = [System.BitConverter]::ToString($hash)
@futurist
futurist / bongo.sh
Last active February 11, 2018 14:56 — forked from nhoening/bongo.sh
Allowing to pass a query for exporting specific data. Added a LIMIT option to limit the number of returned results. Added a debug switch to see errors.
#!/bin/bash
LOADING=false
DEBUG=/dev/null
usage()
{
cat << EOF
usage: $0 [options] <DBNAME>
@joeyklee
joeyklee / getAngleRad.js
Created January 13, 2017 09:33
Get the angle in radians between two points
function getAngleRad(p1, p2){
// returns the angle between 2 points in radians
// p1 = {x: 1, y: 2};
// p2 = {x: 3, y: 4};
return Math.atan2(p2.y - p1.y, p2.x - p1.x);
}
@bangonkali
bangonkali / symlink.sh
Created August 9, 2016 15:03
Creating a symlink for visual studio code on mac os x el capitan
@jeromedalbert
jeromedalbert / gist:7476f445b7538b488c6ec34b5c4f3da4
Created May 28, 2016 19:08
Installing the Docker Toolbox on OS X with brew
brew cask install dockertoolbox
docker-machine create --driver virtualbox default
docker-machine ls
eval $(docker-machine env default)
Put the exports in this eval in your .zshrc or .bashrc if you use bash
@davimacedo
davimacedo / curl.sh
Last active June 23, 2021 21:33
Example of importing data with cloud functions. See a live example at https://www.back4app.com/database/davimacedo/parse-import-example
curl -X POST \
-H "X-Parse-Application-Id: LL9oIdzIkmwl5xyowQQu0fTmXyUWfet9RuAzwHfj" \
-H "X-Parse-REST-API-Key: R3S8PYQKuzeV4c8MUeO5ved46C50MEp56boDHW1O" \
-H "Content-Type: application/json" \
-d @data.json \
https://parseapi.back4app.com/functions/import
@AlphaNerd
AlphaNerd / controller.js
Created April 20, 2016 11:33
Like/Unlike Button - Great for using localStorage data and using a service in backend to update server.
$scope.i = 0;
$scope.likeClick = function(data){
$scope.data[$scope.i].likes.byUser = $dataservice.likeClick(data);
}
@orangeeli
orangeeli / include-relation.js
Created December 25, 2015 23:02
A small code snippet that shows how to return items from a relation since include is only for pointer columns (parse.com javascript SDK)
function get(req, res) {
var Foo,
query,
foos;
Foo = Parse.Object.extend("Foo", {}, {});
query = new Parse.Query(Foo);
foos = [];
@joshnuss
joshnuss / app.js
Last active March 4, 2024 00:01
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection