Skip to content

Instantly share code, notes, and snippets.

View tobsn's full-sized avatar

Tobsn tobsn

  • US/EU/SEA
View GitHub Profile
@tobsn
tobsn / LocalSettings.php
Created March 27, 2018 01:39 — forked from amrav/LocalSettings.php
Slack integration using Redis
# Slack integration
require_once "$IP/extensions/Slack/Slack.php";
# Slack extension configuration options
$wgSlackWebhookURL = "https://hooks.slack.com/services/some-webhook-url"
$wgSlackUserName = "batman";
$wgSlackChannel = "#recent-changes";
$wgSlackIconURL = "http://i.picresize.com/images/2015/09/20/tdpsU.jpg";
$wgSlackLinkUsers = true;
@tobsn
tobsn / .ebextensions production.config
Last active March 1, 2018 21:58
elastic beanstalk RDS wordpress with S3 media upload
option_settings:
- namespace: aws:autoscaling:asg
option_name: MinSize
value: 2
- namespace: aws:autoscaling:asg
option_name: MaxSize
value: 6
- namespace: aws:elasticbeanstalk:application:environment
option_name: env
value: production
@tobsn
tobsn / localstorage.polyfillcheck.js
Last active December 12, 2017 21:32
localStorage polyfill with check first
(function(){
if(
!(function(t){
try {
window.localStorage.setItem(t,t);
window.localStorage.removeItem(t);
return true;
} catch(e) {
return false;
}
@tobsn
tobsn / gist:796fcbea5b3aa0827ae20a62ec277986
Created November 23, 2017 12:12
Set subdomain Allow Origin on Apache and return 200 OK on OPTONS preflight request for ajax use without jsonp
SetEnvIf Origin ^(https?://.+\.yourdomain\.com(?::\d{1,5})?)$ CORS_ALLOW_ORIGIN=$1
Header always set Access-Control-Allow-Origin %{CORS_ALLOW_ORIGIN}e env=CORS_ALLOW_ORIGIN
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
Header merge Vary "Origin"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
@tobsn
tobsn / list.txt
Created November 7, 2017 00:32
US EAST EC2 Whitelist Optimized CIRD
13.58.0.0/15
18.216.0.0/13
23.20.0.0/14
34.192.0.0/12
34.224.0.0/12
35.153.0.0/16
35.168.0.0/13
50.16.0.0/15
50.19.0.0/16
52.0.0.0/13
@tobsn
tobsn / xd60v2.json
Created July 11, 2017 23:36
XD60 v2 kbfirmware config json
{"version":1,"keyboard":{"keys":[{"id":0,"legend":"~\n`","state":{"x":0,"y":0,"r":0,"rx":0,"ry":0,"w":1,"h":1,"x2":0,"y2":0,"w2":0,"h2":0},"row":0,"col":0,"keycodes":[{"id":"KC_ESC","fields":[]},{"id":"KC_GRV","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]}]},{"id":1,"legend":"!\n1","state":{"x":1,"y":0,"r":0,"rx":0,"ry":0,"w":1,"h":1,"x2":0,"y2":0,"w2":0,"h2":0},"row":0,"col":1,"keycodes":[{"id":"KC_1","fields":[]},{"id":"KC_F1","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"i
@tobsn
tobsn / engineer.md
Created January 5, 2017 10:18 — forked from v0lkan/engineer.md
The Evolution of a Software Engineer

This gist outlines the change in the depth and breadth of the tasks and responsibilities of a software engineer as she continuously improves herself.

I created this to supplement a discussion in an internal slack group; then I though the rest of the world might benefit from this too.

Contributions are always welcome.

Associate Engineer

  • Knowledge
@tobsn
tobsn / return image with text formatted to fit within given width.php
Created June 1, 2010 17:00
really ugly code to generate text within an transparent imagine of a given width without running over the borders (only pixel fonts are supported because of the fixed width)
function formattextimg( $text, $width = 960, $color = array( 0, 0, 0 ), $font = 2 ) {
$width = ( ( isset( $width ) && is_numeric( $width ) ) ? ( ( $width >= 100 ) ? (int)$width : 100 ) : 960 );
$text = str_replace( array( '<b>', '</b>', '<strong>', '</strong>' ), '|', $text );
$text_b = preg_split( '/\|/', $text, -1, PREG_SPLIT_OFFSET_CAPTURE );
foreach($text_b as $k => $tb){if($k%2!=0){$textbold[($tb[1]-1)]=$tb[0];}}
$text = str_replace('|','',$text);
for( $i = 0; $i < strlen( $text ); $i++ ) {
if( $string_c >= ( $width - ( (int)(imagefontwidth( $font ) / 2 ) ) ) ) {
$space = strrpos( $string, ' ' );
$string_sub = substr( $string, 0, $space );
@tobsn
tobsn / unsure.txt
Created September 9, 2016 11:16
unsubscribe in different languages
We wish you wouldn't go, but we want to respect your inbox. Please verify your email address below. Thank you!
Nous ne souhaiterions pas vous perdre, mais nous respectons votre choix. Veuillez vérifier l’adresse ci-dessous. Merci.
@tobsn
tobsn / composer.json
Created March 1, 2016 19:04
deploy magento on elastic beanstalk with composer post install command to write production config
{
"require": {
"magento-hackathon/magento-composer-installer": "3.0.*",
"aydin-hassan/magento-core-composer-installer": "^1.3",
"firegento/magento": "1.9.2.2"
},
"extra": {
"magento-root-dir": "htdocs",
"auto-append-gitignore": true,
"magento-deploystrategy": "copy",