Skip to content

Instantly share code, notes, and snippets.

View kernel-memory-dump's full-sized avatar
💼
Software Architecture is Love, Software Architecture is Life

Sebastian Novak kernel-memory-dump

💼
Software Architecture is Love, Software Architecture is Life
View GitHub Profile
@kernel-memory-dump
kernel-memory-dump / curltest.c
Created March 14, 2017 13:27 — forked from aaronhurt/curltest.c
example code using libcurl and json-c to post and parse a return from http://jsonplaceholder.typicode.com
/**
* example C code using libcurl and json-c
* to post and return a payload using
* http://jsonplaceholder.typicode.com
*
* Requirements:
*
* json-c - https://github.com/json-c/json-c
* libcurl - http://curl.haxx.se/libcurl/c
*
public static Map<String, String> extractujParametreIzZahteva(String resource) {
Map<String, String> parametri = new HashMap<String, String>();
String operacija = parametri.get("operacija");
if(resource.contains("operacija")) {
// index.hmtl?ime=&prezime=&email=&grad=NS&kredit=&operacija=dodaj
String[] parts = resource.split("\\?");
// fetch the other part ime=x&prezime=&email=&grad=NS&kredit=&operacija=dodaj
String params = parts[1];
String[] paramParts = params.split("&");
// ["ime=pera", "prezime=peric" ]
enum AttachmentType {
TEXT, IMAGE, AUDIO, VIDEO
}
// unique dodati rucno u master.xml
// ili liquidbase.xml
entity User {
username String,
package com.ekiras.ss.security.config;
import com.ekiras.ss.security.filter.TokenAuthenticationFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
@kernel-memory-dump
kernel-memory-dump / travis.yml
Last active January 31, 2018 19:38 — forked from ryanjones/travis.yml
Create db/user for test db in travis yml
before_script:
- psql -c "CREATE USER the_user WITH PASSWORD 'passw0000rd' CREATEDB;" -U postgres
- psql -c 'CREATE database the_db_test;' -U postgres
- psql -c 'ALTER DATABASE the_db_test OWNER TO the_user' -U postgres
// https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
function generateUUID() { // Public Domain/MIT
var d = new Date().getTime();
if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
d += performance.now(); //use high-precision timer if available
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
@kernel-memory-dump
kernel-memory-dump / correctuse-example-1.js
Created April 8, 2018 18:33 — forked from itaditya/correctuse-example-1.js
Snippet for Avoiding the async/await hell medium article
async function selectPizza() {
const pizzaData = await getPizzaData() // async call
const chosenPizza = choosePizza() // sync call
await addPizzaToCart(chosenPizza) // async call
}
async function selectDrink() {
const drinkData = await getDrinkData() // async call
const chosenDrink = chooseDrink() // sync call
await addDrinkToCart(chosenDrink) // async call
@kernel-memory-dump
kernel-memory-dump / correctuse-example-2.js
Created April 8, 2018 18:33 — forked from itaditya/correctuse-example-2.js
Snippet for Avoiding the async/await hell medium article
async function orderItems() {
const items = await getCartItems() // async call
const noOfItems = items.length
const promises = []
for(var i = 0; i < noOfItems; i++) {
const orderPromise = sendRequest(items[i]) // async call
promises.push(orderPromise) // sync call
}
await Promise.all(promises) // async call
}
@kernel-memory-dump
kernel-memory-dump / app.js
Created April 24, 2018 11:00 — forked from joshnuss/app.js
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 "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection