Skip to content

Instantly share code, notes, and snippets.

@bradtraversy
bradtraversy / tailwind-webpack-setup.md
Last active May 3, 2024 07:35
Setup Webpack with Tailwind CSS

Webpack & Tailwind CSS Setup

Create your package.json

npm init -y

Create your src folder

Create a folder called src and add an empty index.js file. The code that webpack compiles goes in here including any Javascript modules and the main Tailwind file.

@linyiru
linyiru / decrypt_pdf.py
Last active April 18, 2020 11:55 — forked from bzamecnik/decrypt_pdf.py
Decrypt password-protected PDF in Python.
# Decrypt password-protected PDF in Python.
# cleaned-up version of http://stackoverflow.com/a/26537710/329263
#
# Requirements:
# pip install PyPDF2
#
# Usage: decrypt_pdf('encrypted.pdf', 'decrypted.pdf', 'secret_password')
import sys
from PyPDF2 import PdfFileReader, PdfFileWriter
@jsleetw
jsleetw / gist:9806390
Last active October 3, 2023 08:27
Optimizer image in command line
sudo apt-get install jpegoptim optipng
find . -type f -name "*.jpg" -exec jpegoptim {} \;
find . -type f -name "*.png" -exec optipng {} \;
find . -type f -name "*.jpeg" -exec jpegoptim {} \;
---
sudo apt-get install imagemagick
find . -type f -size +1000k -name "*.jpg" -exec convert {} -resize "2048>x2048>" {} \;
find . -type f -size +1000k -name "*.jpeg" -exec convert {} -resize "2048>x2048>" {} \;
find . -type f -size +1000k -name "*.png" -exec convert {} -resize "2048>x2048>" {} \;
@wancw
wancw / ls-migrations-then-checkout
Last active December 16, 2016 18:55
列出切換 branch 前需要 rollback 的 South migration。
#!/usr/bin/env zsh
if [[ $# != 1 ]]; then
cat - << USAGE
Usage: `basename $0` <branch>
USAGE
return 1
fi
local old_branch=$(git rev-parse --abbrev-ref HEAD)
@danyshaanan
danyshaanan / pixelate_image.py
Last active April 20, 2022 12:32
A Python script to pixelate an image and add a thin black margin between the simulated pixels.
from PIL import Image
backgroundColor = (0,)*3
pixelSize = 9
image = Image.open('input.png')
image = image.resize((image.size[0]/pixelSize, image.size[1]/pixelSize), Image.NEAREST)
image = image.resize((image.size[0]*pixelSize, image.size[1]*pixelSize), Image.NEAREST)
pixel = image.load()
@itszero
itszero / fetch.sh
Created June 27, 2012 07:23
iTunes TW Feed List
#!/bin/sh
wget -O xml/top_albums.xml http://itunes.apple.com/tw/rss/topalbums/limit=300/explicit=true/xml
wget -O xml/new_releases.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/newreleases/sf=143470/limit=300/rss.xml
wget -O xml/just_added.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/justadded/sf=143470/limit=300/rss.xml
wget -O xml/featured_albums.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/featuredalbums/sf=143470/limit=300/rss.xml
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@oodavid
oodavid / README.md
Created March 26, 2012 17:05
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@ikeikeikeike
ikeikeikeike / gist:2028340
Created March 13, 2012 11:46
django logging fluentd
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': "%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]"
},
},
'handlers': {
'fluentinfo':{
@hrldcpr
hrldcpr / tree.md
Last active May 1, 2024 00:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!