Skip to content

Instantly share code, notes, and snippets.

View josefanostylus's full-sized avatar
🎯
Focusing

josefanostylus

🎯
Focusing
View GitHub Profile
@josefanostylus
josefanostylus / thumbs.md
Created June 20, 2022 14:23 — forked from bengarrett/thumbs.md
Generate and optimise thumbnails using GraphicsMagick and pngquant

Generate and optimise thumbnails using GraphicsMagick and pngquant

Install

Install gm and pngquant.

apt-get install gm pngquant

Generate

Generate a thumbnail. You can replace -thumbnail with -resize for a clearer thumbnail that will result in a larger file size.

@Pilotin
Pilotin / tailwindcss-postcss-autoprefixer-cssnano.md
Last active March 20, 2024 09:09
TailwindCSS + PostCSS + AutoPrefixer + CSS Nano Install

Setup

  • Create new working folder /tailwind/. Open in terminal
  • run npm init -y
  • run npm install tailwindcss @tailwindcss/custom-forms postcss-cli autoprefixer postcss-nested cssnano
  • run npx tailwind init
  • Edit tailwind.config.js and replace plugins: [], with:
plugins: [
@HarshithaKP
HarshithaKP / SessionPersistence.js
Last active February 12, 2022 09:19
Demonstration of how user session can be persisted across redirects, with an express server and request client.
var express = require('express')
var session = require('express-session')
var app = express()
var r = require('request')
// By default cookies are disabled, switch it on
var request = r.defaults( { jar:true } )
app.use(session({ secret: 'keyboard cat',saveUninitialized : false, resave : false, cookie: { maxAge: 60000 }}))
@basimhennawi
basimhennawi / graphicsmagick.txt
Last active May 24, 2022 19:20
Graphicsmagick and Imagemagick static binaries for AWS Lambda
# Must be run on an Amazon Linux AMI that matches AWS Lambda's runtime
# As of Dec 6, 2018, this is Amazon Linux AMI – amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2
# Check latest from here: https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
# SSH to Amazon Linux AMI instance, that you just created:
ssh -i ${EC2_KEY} ${EC2_USERNAME}@${EC2_IP}
sudo yum -y install libpng-devel libjpeg-devel libtiff-devel gcc
# GraphicsMagick download latest stable as of Dec 6, 2018, this is 1.3.31 (latest stable)
curl -O https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.31/GraphicsMagick-1.3.31.tar.gz
@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active March 23, 2024 09:04
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

@mars
mars / create-react-app-on-heroku.sh
Created July 29, 2016 01:12
Create a React app & deploy to Heroku
## Global install of the app generator
npm install -g create-react-app
## Setup the app (first-time only)
create-react-app my-app
cd my-app
git init
# Create the Heroku app; requires free account at https://www.heroku.com/
heroku create -b https://github.com/heroku/heroku-buildpack-static.git
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@bengarrett
bengarrett / thumbs.md
Last active June 20, 2022 14:23
Generate and optimise thumbnails using GraphicsMagick and pngquant

Generate and optimise thumbnails using GraphicsMagick and pngquant

Install

Install gm and pngquant.

apt-get install gm pngquant

Generate

Generate a thumbnail. You can replace -thumbnail with -resize for a clearer thumbnail that will result in a larger file size.

@falkolab
falkolab / download.js
Created July 30, 2014 08:16
Download file by http with progress (NodeJS)
function download(fileUrl, apiPath, callback) {
var url = require('url'),
http = require('http'),
p = url.parse(fileUrl),
timeout = 10000;
var file = fs.createWriteStream(apiPath);
var timeout_wrapper = function( req ) {
return function() {
@newtriks
newtriks / file.js
Created February 6, 2014 18:35
NodeJS module to download multiple files from Amazon S3
#!/usr/bin/env node
var Q = require('q'),
FS = require('fs'),
PB = require('progress'),
AWS = require('aws-sdk'),
conf = new require('../config')();
AWS.config.update(conf.aws_credentials);