Skip to content

Instantly share code, notes, and snippets.

View emadehsan's full-sized avatar
🤸‍♂️
Overthinking about overthinking

Emad Ehsan emadehsan

🤸‍♂️
Overthinking about overthinking
View GitHub Profile
@Leotomas
Leotomas / chrome_install_headless.sh
Created August 2, 2016 11:03
Install Chrome headless on Ubuntu
export CHROME_BIN=/usr/bin/google-chrome
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
@emadehsan
emadehsan / Test.md
Last active August 14, 2019 13:02
Automatically set cookie in Postman

In the Tests tab of your request, type this code

let cookie = postman.getResponseHeader("Set-Cookie");
postman.setEnvironmentVariable("cookie", cookie);

This will set an environment vairable. In all the requests that need cookie, add to the Request Header

Key: Cookie

@sivaprabug
sivaprabug / postman.js
Created July 5, 2017 10:23
Set cookie value and csrf value as global postaman value
tests["Status code is 200"] = responseCode.code === 200;
// getting CSRF token value from responseBody and stored in global variable
var data = JSON.parse(responseBody);
console.info("CSRF Token Value = " + data.CSRFToken);
postman.setGlobalVariable("csrftoken", data.CSRFToken);
// getting QSESSIONID value from Cookie and stored in global variable
var qsessionidValue = postman.getResponseCookie("QSESSIONID").value
console.log(qsessionidValue);
@lsm
lsm / export_gridfs.sh
Created June 30, 2011 11:20
Export files from MongoDB GridFS with directory paths
#!/bin/bash
# http://www.vladimirm.com/blog/2011/06/export-files-from-mongodb-gridfs-with-directory-paths/
_host="${1:?Usage: gridfs host db}"
_db="${2:?Usage: gridfs host db}"
while read -r line; do
file=$(echo "$line" | awk -F'\t' '{ print $1 }')
[[ $file == 'connected to'* ]] && continue
directory=${file%/*}
mkdir -p $directory
@tuxite
tuxite / d3.windArrow.js
Created September 17, 2014 13:28
D3 JS script to draw a wind arrow
/* Creates a wind arrow for display in station model */
/* The default size of the arrow is: width = 8, height = 2.
The size is then given by the @arrowWidth parameter.
The canvas is a square of 2*arroWidth.
The arrow is drawn in the center of the square and rotated to the corresponding angle (@direction).
*/
var WindArrow = function (speed, direction, container, arrowWidth) {
'use strict';
var index = 0,
@planetoftheweb
planetoftheweb / tweets_json.php
Created July 2, 2013 23:33
This gist will let you retrieve a series of tweets using the twitter v1.1 API. There's a few steps you have to do before you use this. 1. First, you need to go to http://dev.twitter.com/apps and create a new application. 2. You'll also need to download this library. https://github.com/themattharris/tmhOAuth (You only need the tmhOAuth.php file) …
<?php
require 'tmhOAuth.php'; // Get it from: https://github.com/themattharris/tmhOAuth
// Use the data from http://dev.twitter.com/apps to fill out this info
// notice the slight name difference in the last two items)
$connection = new tmhOAuth(array(
'consumer_key' => '',
'consumer_secret' => '',
'user_token' => '', //access token
@benw
benw / load-hbs-partials.js
Created October 3, 2012 00:29
Loads partial handlebars templates from files in a directory
// Helps with this problem:
// http://stackoverflow.com/questions/8059914/express-js-hbs-module-register-partials-from-hbs-file
var hbs = require('hbs');
var fs = require('fs');
var partialsDir = __dirname + '/../views/partials';
var filenames = fs.readdirSync(partialsDir);
@bhurlow
bhurlow / gist:3043629
Created July 3, 2012 21:57
Linux Screen Cheat Sheets
–ctrl a c -> cre­ate new win­dow
–ctrl a A -> set win­dow name
–ctrl a w -> show all win­dow
–ctrl a 1|2|3|… -> switch to win­dow n
–ctrl a ” -> choose win­dow
–ctrl a ctrl a -> switch between win­dow
–ctrl a d -> detach win­dow
–ctrl a ? -> help
–ctrl a [ -> start copy, move cur­sor to the copy loca­tion, press ENTER, select the chars, press ENTER to copy the selected char­ac­ters to the buffer
–ctrl a ] -> paste from buffer
@domenic
domenic / portable-node.md
Created May 25, 2012 21:03
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation

@pletchm
pletchm / Xarray Example Cheatsheet.ipynb
Last active April 27, 2023 13:18
Xarray Example Cheatsheet
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.