Skip to content

Instantly share code, notes, and snippets.

@hackjoy
hackjoy / heapdump.js
Last active Feb 21, 2021
Generate a heapdump file for analysis
View heapdump.js
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 Feb 18, 2019
terraform-new-relic
View 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
View react-example.js
import React from 'react';
export default React.createClass({
displayName: 'Button',
propTypes: {
text: React.PropTypes.string.isRequired,
isDisabled: React.PropTypes.bool
},
getDefaultProps() {
return {
View atom_packages.txt
├── 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
View es6.js
// 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);
View 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"
View bottles_lib_6.rb
class Bottles
# ... verse() & verses() methods not shown for brevity ...
def song
verses(99,0)
end
end
View 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
View 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 Aug 29, 2015
bottles_test_2.rb
View 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