Skip to content

Instantly share code, notes, and snippets.

View Thesephi's full-sized avatar
:octocat:
active at 3am

dk Thesephi

:octocat:
active at 3am
View GitHub Profile
@Thesephi
Thesephi / heroku-database-restore
Created December 25, 2014 04:47
Restore a Heroku database
heroku pgbackups:restore HEROKU_POSTGRESQL_<COLOR>_URL 'http://path.to.your.db'
@Thesephi
Thesephi / list-all-target-directories
Created January 3, 2015 02:46
List all "target" directories inside a build project (created for an SBT - Scala project)
find . -name target -type d -exec ls -d {} \;
@Thesephi
Thesephi / http.req.js
Last active January 19, 2016 12:35
hook.io hook to run arbitrary HTTP requests
module['exports'] = function httpReq(hook) {
// remove this on production, if you'd care
console.log(hook.params);
console.log(hook.req.path);
console.log(hook.req.method);
console.log(hook.env);
var request = require('request');
var url = (hook.params.url)? decodeURI(hook.params.url) : null;
@Thesephi
Thesephi / error-stack_imagemagick-native_nodejs@8.0.0
Last active June 1, 2017 17:18
Error Stack when installing the npm package imagemagick-native@1.9.3 under NodeJS@8.0.0
> imagemagick-native@1.9.3 install /path/to/my/project/node_modules/imagemagick-native
> node-gyp rebuild
CXX(target) Release/obj.target/imagemagick/src/imagemagick.o
../src/imagemagick.cc:262:40: error: no member named 'FilterTypes' in namespace 'Magick'
image.filterType( (Magick::FilterTypes)option_info );
~~~~~~~~^
../src/imagemagick.cc:327:30: error: no matching constructor for initialization of 'Magick::Geometry'
Magick::Geometry resizeGeometry( resizewidth, resizeheight, 0, 0, 0, 0 );
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Thesephi
Thesephi / it.should.work.spec.js
Created January 29, 2019 09:07
it should work
describe('test', () => {
it('should work', () => {
});
}
@Thesephi
Thesephi / gpg_keys_management.sh
Last active September 11, 2021 13:46
simple gpg key management
# view list of keys available on the system
gpg --list-secret-keys --keyid-format=long
# generate a new key (to be associated with a specific email address for which you'll be prompted)
gpg --full-generate-key # might differ depending on the gpg version being used
# echo pub key to the console
gpg -a --export your@email.example.com
# example use case: sign git commits with your gpg key
@Thesephi
Thesephi / testing-library-and-jest-react-hooks-shallow-co-existence.test.js
Created March 30, 2022 23:51
@testing-library/react-hooks and jest-react-hooks-shallow co-existence
import { renderHook } from '@testing-library/react-hooks'
import enableHooks, { withoutHooks } from 'jest-react-hooks-shallow'
// enable jest-react-hooks-shallow helper by default
enableHooks(jest)
describe('@testing-library/react-hooks renderHook and jest-react-hooks-shallow co-existence', () => {
it('testing-library `renderHook` does NOT work when jest-react-hooks-shallow helper is enabled', () => {
jest.spyOn(console, 'log');
@Thesephi
Thesephi / hello_rust.rs
Last active November 8, 2024 01:58
a simple function written in rust
pub fn main(name: &str) -> String {
let mut ret_val = String::from("xin chào, ");
ret_val.push_str(name);
println!("{}", ret_val);
ret_val
}
// normally `main` isn't supposed to return `String` type
// but this is done on purpose here to support a specially intended use case
@Thesephi
Thesephi / simple.rs
Last active November 8, 2024 02:54
a very simple rust function, to demonstrate on https://zzzz.dev
use std::env;
pub fn main() {
let args: Vec<String> = env::args().collect();
let mut ret_val = String::from("hello, ");
ret_val.push_str(&args[1]);
ret_val.push_str("\n");
ret_val.push_str("try calling me like https://fd96bd80a0d79fe3831f67a461d064b6.run.zzzz.dev/mommy");
println!("{}", ret_val);
}
@Thesephi
Thesephi / simple.py
Created November 8, 2024 16:21
a simple function written in python
import sys
import os
print("I love ya")