Skip to content

Instantly share code, notes, and snippets.

View bichotll's full-sized avatar
😶
Doing stuff..

Jaume Tarradas Llort bichotll

😶
Doing stuff..
View GitHub Profile

Helpful stuff

check current network configuration

cat /etc/resolv.conf

start web server

sudo python3 -m http.server 80

check current ip

ip a

@bichotll
bichotll / __dirname.js
Created September 22, 2021 08:02
__dirname and __filename in ESM node
import { URL } from 'url'; // in Browser, the URL in native accessible on window
const __filename = new URL('', import.meta.url).pathname;
// Will contain trailing slash
const __dirname = new URL('.', import.meta.url).pathname;
class SessionToken {
}
class IDP {
static token
}
SELECT client.id, client.name, count(user.clientId) as total_users
from client
left join user
on (client.id = user.clientId)
group by
client.id
having total_users > 2
import React, { useState, useEffect } from "react";
type MousePositionType = {
x: number;
y: number;
};
type WindowSizeType = {
height: number;
width: number;
@bichotll
bichotll / UserController.php
Last active May 9, 2019 10:34
symfony2 - forced and secure user authentication (login) and logout (fos rest example)
//reference http://hasin.me/2013/10/27/how-to-login-a-user-programatically-in-symfony2/
//...
class UserController extends FOSRestController implements ClassResourceInterface {
//...
/**
* Authenticate a user with Symfony Security
*
@bichotll
bichotll / load_disqus_comments_android.java
Last active April 25, 2019 15:19
Load disqus comments with a htmlview in Android
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comments);
String htmlComments = getHtmlComment("yourId", "yourShortName");
webDisqus = (WebView) findViewById(R.id.disqus);
// set up disqus
WebSettings webSettings2 = webDisqus.getSettings();
@bichotll
bichotll / assertions-compareScreenshot.js
Created August 3, 2016 14:03 — forked from umarmw/assertions-compareScreenshot.js
Nightwatch with Visual Regression testing
// location: ./assertions/compareScreenshot.js
var resemblejs = require('node-resemble-js'),
fs = require('fs');
exports.assertion = function(filename, expected) {
var screenshotPath = 'test/screenshots/',
baselinePath = screenshotPath + 'baseline/' + filename,
resultPath = screenshotPath + 'results/' + filename,
diffPath = screenshotPath + 'diffs/' + filename;
@bichotll
bichotll / zoomCalc.js
Created November 9, 2018 14:06
zoom calculation from lat, long and km scuare
function calcLong(lat, long, distance) {
var earth = 6378.137, //radius of the earth in kilometer
pi = Math.PI,
cos = Math.cos,
m = (1 / ((2 * pi / 360) * earth)) / 1000; //1 meter in degree
return long + (distance * m) / cos(lat * (pi / 180));
}
function calcLat(lat, long, distance) {
@bichotll
bichotll / pull-request.md
Last active October 9, 2018 10:00
How to work properly with Git

How to work nicely and sound with Git (Gitlab/Github):

1 - Let's get our local updated before everything git fetch --all

2 - Now we start a new branch (from master!) git checkout origin/master (or git checkout upstream/master or similar depending on your setup) and git checkout -b feature-a