Skip to content

Instantly share code, notes, and snippets.

View borantula's full-sized avatar

Bora Yalcin borantula

View GitHub Profile
@philfreo
philfreo / 1_pdf.py
Last active January 30, 2024 16:20
Three ways to make a PDF from HTML in Python (preferred is weasyprint or phantomjs)
def render_pdf_weasyprint(html):
from weasyprint import HTML
pdf = HTML(string=html.encode('utf-8'))
return pdf.write_pdf()
def render_pdf_xhtml2pdf(html):
"""mimerender helper to render a PDF from HTML using xhtml2pdf.
Usage: http://philfreo.com/blog/render-a-pdf-from-html-using-xhtml2pdf-and-mimerender-in-flask/
"""
@ansulev
ansulev / nginx-force-non-www-ssl-pwsite.conf
Last active August 27, 2017 12:42
Nginx site configuration for ProcessWire with forced SSL and www to non-www redirect
# nginx site config for processwire with forced SSL and www to non-redirect
# redirect from www to non-www forced SSL
# uncomment, save file and restart Nginx to enable
# if unsure use return 302 before using return 301
server {
server_name domain.com www.domain.com;
return 301 https://$server_name$request_uri;
}
@itzikbenh
itzikbenh / gulpfile.js
Last active March 29, 2023 17:17
Gulp configuration for my WordPress theme development
/*
Create package.json and install all packages:
1. npm init
2. npm install -g gulp
3. npm install gulp gulp-babel babel-preset-es2015 gulp-concat gulp-csso gulp-rename gulp-sass gulp-uglify gulp-watch browser-sync --save-dev
Expected file structure:
./css/src/*.scss
@ferdiunal
ferdiunal / array2json.php
Last active June 27, 2023 00:54
Ülkelerin İl, İlçeleri. Şimdilik Türkiye'yi ekleyebildim.
#!/usr/bin/env php
<?php
/**
* @author Ferdi ÜNAL
* @email ferdi@unal.pw
*/
$location = require "location.php";
$json = fopen('location.json', 'w');
@tcrammond
tcrammond / target-metro.scss
Last active October 2, 2020 13:50
A sass mixin to write css that targets only IE 10 and IE 11
// Thanks http://philipnewcomer.net/2014/04/target-internet-explorer-10-11-css/
/*
Usage:
@include target-metro {
color: cyan;
}
*/
@mixin target-metro {
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
@Restuta
Restuta / framework-sizes.md
Last active March 7, 2024 00:01
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@Yimiprod
Yimiprod / difference.js
Last active July 13, 2024 15:07
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
@tomazzaman
tomazzaman / README.md
Last active September 17, 2023 20:59
Gulp workflow for WordPress theme development

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
@seanmcn
seanmcn / gist:62a021a765ad4f8e593b
Last active July 20, 2024 16:30
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
@mattyza
mattyza / matty-double-post-type-rewrite-rule-example.php
Last active October 16, 2023 06:49
A WordPress custom rewrite rule example, combining two post types.
<?php
/**
* Plugin Name: Double Post Type Rewrite Rule Example
* Plugin URI: https://gist.github.com/mattyza/7dfd156992f23835f68e
* Description: Adds a custom rewrite rule to mimic http://domain.com/post-type-01/post-type-02/.
* Author: Matty Cohen
* Author URI: http://matty.co.za/
* Version: 1.0.0
* Stable tag: 1.0.0
* License: GPL v3 - http://www.gnu.org/licenses/old-licenses/gpl-3.0.html