Skip to content

Instantly share code, notes, and snippets.

View philipstanislaus's full-sized avatar

philipstanislaus

View GitHub Profile
@philipstanislaus
philipstanislaus / includeJQuery.js
Created January 29, 2016 08:38
Include jQuery in any page from console
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-2.2.0.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
jQuery.noConflict();
@philipstanislaus
philipstanislaus / JavaScript's prototypical inheritance.js
Last active June 28, 2017 06:58
JavaScript inheritance (prototype, __proto__, constructor) in ES2015/ES6 and ES5
class Animal {
animalProp() {}
}
// ES2015/ES6
class Cat extends Animal {
catProp() {}
}
const myCat = new Cat()
@philipstanislaus
philipstanislaus / Drop all tables.sql
Created August 4, 2017 07:47
Drop all tables from one schema in Postgres
select 'drop table if exists "' || tablename || '" cascade;'
from pg_tables
where schemaname = 'public'; -- or any other schema
@philipstanislaus
philipstanislaus / optional_values_with_nil_pointers_test.go
Created September 3, 2019 16:02
Optional values with nil pointers
package playground_optional_values_with_nil_pointers
import (
"fmt"
"testing"
"github.com/ChainSafe/gossamer/codec"
)
// Bool represents boolean values
@philipstanislaus
philipstanislaus / optional_values_with_empty_field_test.go
Created September 3, 2019 16:03
Optional values with empty field
package playground_optional_values_with_nil_pointers
import (
"fmt"
"testing"
"github.com/ChainSafe/gossamer/codec"
)
// Bool represents boolean values
@philipstanislaus
philipstanislaus / docker stop and remove all containers.sh
Last active March 15, 2023 07:29
Stop and remove all Docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@philipstanislaus
philipstanislaus / docker remove all images.sh
Created September 2, 2016 16:20
Remove all Docker images
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)
@philipstanislaus
philipstanislaus / add_base_commit.sh
Last active December 1, 2023 10:58
Create empty git base commit for a full code review
# create empty base commit that will be the reference for our code review
git checkout --orphan base
git rm -r --cached .
git clean -fxd
git commit --allow-empty -m "Start of the review"
# create and checkout review branch that will include the latest code that should be reviewed
git checkout -b review
# merge main branch into that new review branch
@philipstanislaus
philipstanislaus / gist:c7de1f43b52531001412
Last active April 5, 2024 16:01
JavaScript: Save a blob to disc
var saveBlob = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (blob, fileName) {
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);