Skip to content

Instantly share code, notes, and snippets.

View Narven's full-sized avatar
👾
Walking to the fridge...

P Ξ D R O L U Z Narven

👾
Walking to the fridge...
View GitHub Profile
@Narven
Narven / create_post.exs
Created October 12, 2021 06:24 — forked from stevedomin/create_post.exs
Using UUIDs as primary key with Ecto
defmodule MyBlog.Repo.Migrations.CreatePost do
use Ecto.Migration
def change do
create table(:posts, primary_key: false) do
add :id, :uuid, primary_key: true
add :body, :string
add :word_count, :integer
timestamps
@Narven
Narven / setup_tailwind_in_phoenix.md
Created October 9, 2021 10:43 — forked from josephan/setup_tailwind_in_phoenix.md
Add Tailwind CSS to an Elixir/Phoenix Project with PurgeCSS
@Narven
Narven / git-unsorted-log.go
Created May 19, 2021 17:14 — forked from michael-k/git-unsorted-log.go
An example of howto use git2go (https://github.com/libgit2/git2go) which is a libgit2 (https://libgit2.github.com/) bindings package for golang.
/*
requires libgit2
*/
package main
import (
"github.com/libgit2/git2go"
"fmt"

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@Narven
Narven / check.go
Created February 25, 2021 12:33 — forked from mattes/check.go
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@Narven
Narven / .gitlab-ci.yml
Created February 5, 2021 17:27 — forked from ChugunovRoman/.gitlab-ci.yml
Deploy Electron app with gitlab ci
# https://<example.com>/<namespace>/<project>/-/jobs/artifacts/<tag>/download?job=pages
# https://<example.com>/<namespace>/<project>/-/jobs/artifacts/<tag>/raw/<path_to_file>?job=pages
# Where:
# example.com - domain name your gitlab server
# namespace - your name user on the gitlab
# project - your project
# tag - ref of current job.
# If job run on only by tags, than ref will be named as tag name
# If job run on only master, than ref will be named as "master", i.e.: https://<example.com>/<namespace>/<project>/-/jobs/artifacts/master/download?job=pages
# path_to_file - path to file relative from root workspace folder
@Narven
Narven / dummy-web-server.py
Created February 2, 2021 15:21 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@Narven
Narven / server.py
Created February 2, 2021 12:51 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@Narven
Narven / custom-entity-not-found-exception-filter.md
Created January 4, 2021 07:11 — forked from gsusmonzon/custom-entity-not-found-exception-filter.md
Make NestJs returns 404 when EntityNotFoundError exception is thrown

Make NestJs returns 404 when EntityNotFoundError exception is thrown

When using findOrFail() or findOneOrFail() from typeORM, a 500 error is returned if there is no entity (EntityNotFoundError).

To make it returns a 404, use an exception filter as described in https://docs.nestjs.com/exception-filters .

file /src/filters/entity-not-found-exception.filter.ts

@Narven
Narven / ultimate-ut-cheat-sheet.md
Created October 13, 2020 14:58 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest

The Ultimate Unit Testing Cheat-sheet

For Jest, Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies