This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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 | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum AttachmentType { | |
| TEXT, IMAGE, AUDIO, VIDEO | |
| } | |
| // unique dodati rucno u master.xml | |
| // ili liquidbase.xml | |
| entity User { | |
| username String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // taken from https://stackoverflow.com/questions/41082224/expected-to-be-they-look-the-same/41082278 | |
| import 'zone.js/dist/long-stack-trace-zone.js'; | |
| import 'zone.js/dist/async-test.js'; | |
| import 'zone.js/dist/fake-async-test.js'; | |
| import 'zone.js/dist/sync-test.js'; | |
| import 'zone.js/dist/proxy.js'; | |
| import 'zone.js/dist/jasmine-patch.js'; | |
| import { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
OlderNewer