Skip to content

Instantly share code, notes, and snippets.

@FiloSottile
FiloSottile / rasterize.js
Created May 12, 2012 15:38
PhantomJS rasterize.js with "Retina" output
var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 2 || phantom.args.length > 3) {
console.log('Usage: rasterize.js URL filename');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 1280, height: 1024 };
@pixelhandler
pixelhandler / pre-push.sh
Last active July 2, 2024 11:27
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
@plentz
plentz / nginx.conf
Last active July 17, 2024 09:16
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@artturik
artturik / gist:a15d890dcfedfe8af813
Last active August 14, 2022 13:38
Convert PhantomJs cookies to NetScape HTTP cookie file format
// Convert PhantomJs cookies to NetScape HTTP cookie file format
// NOTE: It dose not create NetScape HTTP cookie file, this function return only cookie file contents
// NOTE: PhantomJs do not store "host only" cookie param, all cookies will have "host only" param set to false (line 15)
// I use this function to export PhantomJs cookies to CURL cookiejar file
// This is modified version of EditThisCookie cookie_helpers.js cookiesToString function
// USAGE: phantomJsCookiesToNetScapeString(phantom.cookies);
var phantomJsCookiesToNetScapeString = function(cookies) {
var string = "";
string += "# Netscape HTTP Cookie File\n";
@iangcarroll
iangcarroll / Security.php
Last active April 19, 2021 23:32
Expose (a PHPIDS fork) middleware for Laravel. Assumes it's already included via composer.
<?php namespace App\Http\Middleware;
use Closure;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Log;
class Security {
/**
@artturik
artturik / translate.html
Created April 4, 2016 09:09
Forced Google Translate (also can be used as April Fools Day joke)
<!--
This code will translate page contents automatically (without user input)
Settings located at line 9, current script will translate english to estonian
-->
<style>#google_translate_element,.skiptranslate{display:none;}body{top:0!important;}</style>
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'et', autoDisplay: false}, 'google_translate_element');
var a = document.querySelector("#google_translate_element select");

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@artturik
artturik / DumpObject.php
Created August 30, 2016 13:14
Dump object to array; convert all object accessible and non-accessible variables to array (public, protected, private, static properties and constants)
<?php
/*
Returns array with object properties, static properties and constants
Can be used for:
* Object to array conversion
* Get all properties (protected and private) list outside the class
* Get protected property value outside the class
* Get private property value outside the class
@meetmatt
meetmatt / gist:d5dd2ecae37fbabb483dffba2d6dbec6
Created November 3, 2016 13:33
Show installed packages reverse sorted by size in alpine
apk info | xargs -n1 -I{} apk info -s {} | xargs -n4 | awk '{print $4,$1}' | sort -rn