This file contains 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
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
This file contains 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
var constants = require('./constants'); | |
function extractPlatformFromUserAgent(reqHeaders) { | |
if (!!reqHeaders['user-agent'].match(/iOS/) || !!reqHeaders['user-agent'].match(/iPhone/) || !!reqHeaders['user-agent'].match(/iPad/)) { | |
return constants.platform.ios; | |
} else if (!!reqHeaders['user-agent'].match(/Android/)) { | |
return constants.platform.android; | |
} else { | |
return null; | |
} |
This file contains 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
/* | |
* Node.js Sample Server with Restify | |
* Copyright (C) 2014 - Thiago Uriel M. Garcia | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains 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
const getQueryParams = function (req) { | |
let query = req.url.split('?'); | |
let queryParams = {}; | |
if (query.length >= 2) { | |
let params = query[1].split('&'); | |
params.forEach((keyValuePair) => { | |
try { | |
let key = keyValuePair.split('=')[0]; | |
let value = keyValuePair.split('=')[1]; | |
queryParams[key] = value; |
This file contains 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
{ | |
"Author": "Garen", | |
"Message": "Hello World" | |
} |
This file contains 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 sealed partial class MainPage : Page | |
{ | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
this.Loaded += MainPage_Loaded; | |
} | |
private void MainPage_Loaded(object sender, RoutedEventArgs e) | |
{ |
This file contains 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
// This problem was inspired by this original tweet by Max Howell: | |
// Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off. | |
// So, let's invert a binary tree in Javascript | |
// Original Tree | |
// 4 | |
// / \ | |
// 2 7 | |
// / \ / \ |
This file contains 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
const fs = require('fs').promises | |
(async () => { | |
try { | |
const data = JSON.parse(await fs.readFile('/path/to/file.json', 'utf8')) | |
} catch(err) { | |
console.error(err) | |
} | |
})() |
This file contains 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
:loop | |
start "My Great App Name" "C:\Users\Garen\Desktop\greatapp.exe" "param1" | |
timeout /t 600 | |
goto loop |
This file contains 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
function nonce(length) { | |
var text = ''; | |
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
for (var i = 0; i < length; i++) { | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
} | |
return text; | |
} | |
module.exports = nonce; |
OlderNewer