Skip to content

Instantly share code, notes, and snippets.

@hackjoy
hackjoy / heapdump.js
Last active February 21, 2021 18:36
Generate a heapdump file for analysis
router.post(
'/heapdump-4E5AB3A6ECC24CD5B413A6D4DB5DB02FB4907018',
auth(config.server.authToken),
asyncHandler(async (req, res, next) => {
const { logger } = dependencies;
const hostname = os.hostname();
const filepath = '/tmp/';
const filename = `${Date.now()}.heapsnapshot`;
try {
heapdump.writeSnapshot(filepath + filename, err => {
@hackjoy
hackjoy / terraform-new-relic
Last active February 18, 2019 15:09
terraform-new-relic
Error: Error applying plan:
4 error(s) occurred:
* newrelic_alert_policy_channel.app1: 1 error(s) occurred:
* newrelic_alert_policy_channel.app1: Internal Server Error
* newrelic_alert_policy_channel.app2: 1 error(s) occurred:
* newrelic_alert_policy_channel.app2: Internal Server Error
@hackjoy
hackjoy / react-example.js
Last active November 11, 2015 19:26
React Example
import React from 'react';
export default React.createClass({
displayName: 'Button',
propTypes: {
text: React.PropTypes.string.isRequired,
isDisabled: React.PropTypes.bool
},
getDefaultProps() {
return {
@hackjoy
hackjoy / atom_packages.txt
Created August 17, 2015 23:02
Atom packages
├── Stylus@1.1.0
├── Zen@0.16.2
├── advanced-new-file@0.4.3
├── atom-beautify@0.28.11
├── atom-jade@0.3.0
├── atom-lint@0.20.1
├── atom-rails@0.4.0
├── atomatigit@1.5.4
├── auto-indent@0.5.0
├── auto-update-packages@1.0.0
// Interpolate variable bindings
var name = "Bob", time = "today";
`Hello ${name}, how are you ${time}?`
// Arrows
// e => {}
// function(e){}
// Expression bodies
var odds = evens.map(v => v + 1);
@hackjoy
hackjoy / bottles_lib_7.rb
Created August 19, 2014 17:51
bottles_lib_7.rb
class Bottles
def verse(num)
case num
when 0
"No more bottles of beer on the wall, no more bottles of beer.\n" +
"Go to the store and buy some more, 99 bottles of beer on the wall.\n"
when 1
"1 bottle of beer on the wall, 1 bottle of beer.\n" +
"Take it down and pass it around, no more bottles of beer on the wall.\n"
@hackjoy
hackjoy / bottles_lib_6.rb
Created August 18, 2014 21:14
bottles_lib_6.rb
class Bottles
# ... verse() & verses() methods not shown for brevity ...
def song
verses(99,0)
end
end
@hackjoy
hackjoy / bottles_test_5.rb
Created August 18, 2014 21:11
bottles_test_5.rb
# ... previous setup and tests not shown for brevity ...
def test_the_whole_song
assert_equal bottles.verses(99, 0), bottles.song
end
# skipped tests not shown for brevity
@hackjoy
hackjoy / bottles_test_4.rb
Created August 18, 2014 21:08
bottles_test_4.rb
# ... previous setup and tests not shown for brevity ...
def test_a_few_verses
expected = <<-VERSES
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
1 bottle of beer on the wall, 1 bottle of beer.
Take it down and pass it around, no more bottles of beer on the wall.
@hackjoy
hackjoy / bottles_test_2.rb
Last active August 29, 2015 14:05
bottles_test_2.rb
# ...setup and previous test not shown for brevity ...
def test_another_verse
expected = <<-VERSE
89 bottles of beer on the wall, 89 bottles of beer.
Take one down and pass it around, 88 bottles of beer on the wall.
VERSE
assert_equal expected, bottles.verse(89)
end