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
library(maptools) | |
library(geosphere) | |
# load USA state-level spatial data | |
# download from http://gadm.org | |
# click the 'download' tab | |
# select county = 'united states', file format = 'R', click ok | |
# download 'level 1' for state-level data | |
load("USA_adm1.RData") |
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
redis-cli --raw keys "$PATTERN" | xargs redis-cli del |
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
# Private key | |
openssl genpkey -algorithm RSA -out private.pem -pkeyopt rsa_keygen_bits:2048 | |
# Public key | |
openssl rsa -pubout -in private.pem -out public_key.pem | |
# Private key in pkcs8 format (for Java maybe :D) | |
openssl pkcs8 -topk8 -in private.pem -out private_key.pem | |
## nocrypt (Private key does have no password) |
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
tar -xzf <file>.tar.gz |
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 crypto = require("crypto"); | |
/** | |
* Encrypt 3DES using Node.js's crypto module * | |
* @param data A utf8 string | |
* @param key Key would be hashed by md5 and shorten to maximum of 192 bits, | |
* @returns {*} A base64 string | |
*/ | |
function encrypt3DES(data, key) { | |
const md5Key = crypto.createHash('md5').update(key).digest("hex").substr(0, 24); |
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
keytool -list -v -keystore keystore.jks | |
# Enter password | |
# Check the line "Valid from..." |
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
cd ~ | |
mkdir virtualenvs | |
cd virtualenvs | |
pip install virtualenv | |
virtualenv default # or virtualenv -p python3 default (depends on environments) | |
sudo apt-get install -y python-dev # or python3-dev | |
sudo apt-get install -y libmysqlclient-dev | |
source default/bin/activate |
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 handleSubmit = sinon.spy(); | |
const wrapper = mount( | |
<Provider store={store}> | |
<MyForm onSubmit={handleSubmit} /> | |
</Provider> | |
); | |
// Assume MyForm having a platform select input whose name is "platform" | |
const elem = wrapper.find("Select[name='platform']"); | |
elem.prop("onChange")("iOS"); // Get onChange and call directly instead of the traditional elem.simulate("change", {target: {value: "iOS"}}) for <select> or <input> |
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
from django.test import TestCase | |
from rest_framework.test import APIClient | |
class FileUploadTestCase(TestCase): | |
def test_upload(self): | |
client = APIClient() | |
client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) | |
# or self.client (Django https://docs.djangoproject.com/en/dev/topics/testing/advanced/) | |
response = client.post(reverse('upload-file'), { |
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 r = /t\-test|test/g; // Note: /g | |
var input = "these are test t-test"; | |
var output = input.replace(r, "") // Replace matched with "" |
OlderNewer