Skip to content

Instantly share code, notes, and snippets.

View LukaszWiktor's full-sized avatar

Łukasz Wiktor LukaszWiktor

View GitHub Profile

Build image

docker build --tag <image tag>

Run container exposing port 4444 and mounting /views directory

docker run -p 4444:4444 /${PWD}/views:/code/views <image tag>

List running containers

@alexewerlof
alexewerlof / fetch-response-header.js
Last active February 22, 2023 16:59
converting fetch response headers to a plain javascript object
const fetch = require('node-fetch')
const am = require('am')
async function main() {
const url = 'https://www.example.com'
const response = await fetch(url)
const responseHeaders = Object.fromEntries(resp.headers.entries())
console.dir(responseHeaders)
return responseHeaders
}
@zabirauf
zabirauf / renew-mongo-cert.sh
Last active January 26, 2024 16:23
Renew certificate using certbot for MongoDB
#!/bin/bash
# Define variables
DOMAIN=foo.example.com
# renew cert
certbot renew
# combine latest letsencrypt files for mongo
@biinari
biinari / extract-123-reg-zonefile.js
Last active February 8, 2023 14:23
Script to extract the DNS entries from 123-reg advanced dns page
// Moved to a new home at https://github.com/biinari/zonefile-extract/tree/master/123-reg
@LukaszWiktor
LukaszWiktor / postgres-remove-field-from-json.sql
Created November 25, 2016 16:20
PostrgreSQL - remove a nested JSON field if it's null
-- before: data_json = {object: {id: 123, result: null}}
-- after: data_json = {object: {id: 123}}
UPDATE events
SET data_json = data_json::jsonb #- '{object,result}'
WHERE json_typeof(data_json->'object'->'result') = 'null';
@ostinelli
ostinelli / logentries_manual_setup.md
Last active August 11, 2022 21:37
How to use a single Logentries account on Heroku.

If you have multiple applications on Heroku and would like to use a single Logentries account for all of them, this is how you do it. Basically, do not use add-ons, and send all drains to your account.

  • In your Logentries account, click on Add Log
  • Select Manual
  • In the form that appears, input the following:
    • Log Name: access.log
    • Select Set: new set named myapp-{environment}, for instance myapp-staging (at least, this is how I like to name my entries)
    • Select the Plain TCP, UDP - logs are sent via syslog option
  • Click on Create Log Token
@justmoon
justmoon / custom-error.js
Last active April 22, 2024 17:19 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@grantland
grantland / post.md
Last active February 9, 2023 05:09
RecyclerView item onClick

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder
@homam
homam / AWS_S3_File_Upload.js
Created January 27, 2014 10:08
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }