Skip to content

Instantly share code, notes, and snippets.

View jxub's full-sized avatar
🏯

Jakub Janarek jxub

🏯
View GitHub Profile
@jxub
jxub / node-rules.d.ts
Created March 3, 2020 14:44
Simple typings for the node-rules package (https://github.com/mithunsatheesh/node-rules)
declare module 'node-rules' {
export default class RuleEngine {
constructor(rules?: Rule[] | Rule, options?: object);
register(rule: Rule): any;
sync(): Rule[] | void;
execute(fact: {[x: string]: any}, cb: (data: {result?: any, reason?: any, [x: string]: any}) => void): void;
findRules(filter?: any): Rule[] | void;
turn(state: string, filter: any): Rule[] | void;
prioritize(priority: number, filter: any): Rule[] | void;
toJSON(): string;

lab 5

pass: koReBOKuIDDepwhWk7jZC0RTdopnAYKh command: find . -type f -size 1033c ! -executable

lab 6

pass: DXjZPULLxYr17uwoI01bNLQbtFemEgo7 command: find . -user bandit7 -group bandit6 -size 33c -ls 2>&1 | grep -v find | awk -F " " '{print $NF}' | xargs cat

@jxub
jxub / how-to-squash-commits-in-git.md
Created July 13, 2018 14:54 — forked from patik/how-to-squash-commits-in-git.md
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@jxub
jxub / enumerable-tuple-elixir.ex
Created November 30, 2017 22:47
A way to add implementation of Enum for Tuples in Elixir 😁
defimpl Enumerable, for: Tuple do
def count(tuple) do
tuple_size(tuple)
end
def member?([], _), do {:ok, false}
def member?({}, _), do {:ok, false}
def member?(tuple, elem) do
tuple
|> Tuple.to_list
@jxub
jxub / pandas_labeled_csv_import_to_mongo.py
Created September 22, 2017 11:51
A simple mongoimport for importing csv files with python and pymongo
import pandas as pd
from pymongo import MongoClient
import json
def mongoimport(csv_path, db_name, coll_name, db_url='localhost', db_port=27000)
""" Imports a csv file at path csv_name to a mongo colection
returns: count of the documants in the new collection
"""
client = MongoClient(db_url, db_port)
db = client[db_name]

Keybase proof

I hereby claim:

  • I am jxub on github.
  • I am jxub (https://keybase.io/jxub) on keybase.
  • I have a public key ASC0COBt6HSAbVQUBqTHEWBgAg33-HW_bGa0-73LBnuuswo

To claim this, I am signing this object:

@jxub
jxub / README.md
Created April 1, 2017 14:17 — forked from bih/README.md
Intro to Rails 5 Workshop

Intro to Rails 5 Workshop

0. Configuration

Ruby 2.4.0 & Rails 5.2.0

How to install Ruby 2.4.0

$ curl -sSL https://get.rvm.io | bash -s stable --ruby=2.4.0
@jxub
jxub / StreamToString.go
Last active March 20, 2017 12:07 — forked from tejainece/StreamToString.go
Golang: io.Reader stream to string or byte slice
import "bytes"
func StreamToByte(stream io.Reader) []byte {
buf := new(bytes.Buffer)
buf.ReadFrom(stream)
return buf.Bytes()
}
func StreamToString(stream io.Reader) string {
buf := new(bytes.Buffer)
// functional is a small FP-like library with no dependencies (yet!)
// open-sourcing bits and pieces here on gist :)
package bitbucket.com/jjanarek/x/functional
// Reduce reduces a slice of ints, uints or runes to a single element
// making the pythonic lambda sadly implicit and opinionated
func Reduce(elements []interface{}) interface{} {
switch elements.(type) {
case int: