Skip to content

Instantly share code, notes, and snippets.

View brianbancroft's full-sized avatar
🌲

Brian Bancroft brianbancroft

🌲
View GitHub Profile
@rstacruz
rstacruz / README.md
Last active April 23, 2024 00:19
Setting up Jest with ESM

Setting up Jest with ESM

Here are some different ways on how to set up Jest to support ESM. This applies for Jest v25, Node v13, and Babel v7.

Method A: Native Node.js support

Node v14 and Jest v26 support ESM natively with the --experimental-vm-modules flag.

Install cross-env:

  • Precedence doesn't work as you'd expect (twin.macro and twind solve this)
 const SomeComponent = ({ className }) =>
   <div className={classnames('bg-red', className)} />

 <SomeComponent className="bg-blue"/>

What background color will the component have? The div will end up with class="bg-red bg-blue", so precedence depends on whether the specifiers for .bg-red was generated before or after specifiers for .bg-blue in the css file

  • variants conflicting because you have to specify their order globally in the config, not case-by-case - @JonasKuske (twin.macro and twind solve this)
@chriswhong
chriswhong / maputnik-push.js
Last active February 13, 2019 03:01
Push any mapboxGL map style to maputnik using planning labs' maputnik-push service
// this will only work if window.map === your mapboxgl map instance
// we usually set window.map = map in the callback using map.on('style.load', function () { ... })
fetch('https://maputnik-push.planninglabs.nyc/style', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(window.map.getStyle()),
@chriswhong
chriswhong / downloadroute.js
Created July 10, 2018 05:02
Streaming from ps-promise to json2csv to express response
// This code queries postgresql and streams the results into a csv
// Works like a charm for a download button, no hangup for large files!
const Json2csvTransform = require('json2csv').Transform;
const QueryStream = require('pg-query-stream');
const JSONStream = require('JSONStream');
router.get('/download.csv', async (req, res) => {
const { query } = req;
@skorasaurus
skorasaurus / gist:e1bcdd52d25dc0f71cd4c574a1d91197
Last active March 4, 2018 21:08
installing qgis 3.0 on 16.04 xenial.

(note, there are likely many ways to do this, this is just what worked for me but it should work for you; but nonetheless: proceed at your own risk!

  1. DO you already have qgis installed ? -REMOVE IT.
  2. Are you already use Ubuntugis-unstable ppa? If yes, go to 3. if no, go to 2A.
@ttscoff
ttscoff / changelog.rb
Created August 13, 2017 22:28
Generate release notes from git commit messages
#!/usr/bin/ruby
# A script to automate changelog generation from Git commit messages
#
# For use with a git-flow workflow, it will take changes from the last tagged release
# where commit messages contain NEW, FIXED, and IMPROVED keywords and sort and fromat
# them into a Markdown release note list.
#
# The script takes version information from the macOS command agvtool and bases
# the product name on the first matching Xcode Info.plist found

WannaCry|WannaDecrypt0r NSA-Cyberweapon-Powered Ransomware Worm

  • Virus Name: WannaCrypt, WannaCry, WanaCrypt0r, WCrypt, WCRY
  • Vector: All Windows versions before Windows 10 are vulnerable if not patched for MS-17-010. It uses EternalBlue MS17-010 to propagate.
  • Ransom: between $300 to $600. There is code to 'rm' (delete) files in the virus. Seems to reset if the virus crashes.
  • Backdooring: The worm loops through every RDP session on a system to run the ransomware as that user. It also installs the DOUBLEPULSAR backdoor. It corrupts shadow volumes to make recovery harder. (source: malwarebytes)
  • Kill switch: If the website www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com is up the virus exits instead of infecting the host. (source: malwarebytes). This domain has been sinkholed, stopping the spread of the worm. Will not work if proxied (source).

update: A minor variant of the viru

@echosa
echosa / Brave-issues.md
Last active March 30, 2018 19:04
Brave browser issues
# gradients based on http://bsou.io/posts/color-gradients-with-python
def hex_to_RGB(hex):
''' "#FFFFFF" -> [255,255,255] '''
# Pass 16 to the integer function for change of base
return [int(hex[i:i+2], 16) for i in range(1,6,2)]
def RGB_to_hex(RGB):
''' [255,255,255] -> "#FFFFFF" '''