Skip to content

Instantly share code, notes, and snippets.

View federicosan's full-sized avatar

federicosan

View GitHub Profile
@federicosan
federicosan / related-products.liquid
Created June 24, 2017 05:26 — forked from hhayrapetyan/related-products.liquid
Shopify Venture Theme Related products snippet

##Monads for functional programming (in Elm)

Adaptation of the examples in Philip Wadler's paper "Monads for functional programming" for the Elm language.

These examples can easily be tried out on the online elm playground: http://elm-lang.org/try

@federicosan
federicosan / min-char-rnn.py
Created May 9, 2017 21:37 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@federicosan
federicosan / cleaning_malware_wordpress.md
Created December 23, 2016 20:58 — forked from sandys/cleaning_malware_wordpress.md
cleaning malware from wordpress

Look for any outbound port 80 connections with:

lsof -i :80

You will see your own apache server in that list too, but keep an eye for other stuff.

usually, attacks like this are very obvious in the output of:

ps faux

@federicosan
federicosan / psql_encoding.sql
Created November 14, 2016 21:46 — forked from turboladen/psql_encoding.sql
Script for dealing with creating Postgres databases that complain with: ``` PG::InvalidParameterValue: ERROR: encoding UTF8 does not match locale en_US DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1. ``` ...when trying to create the production DB. Taken from: http://stackoverflow.com/questions/13115692/encoding-utf8-does-not-match-…
sudo su postgres
psql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate=true where datname='template1';
@federicosan
federicosan / gist:eb470dd900f43cca5ff5e74cdef62647
Created July 15, 2016 19:08 — forked from wycks/gist:2315295
Rewrite static theme assets and plugins directory (WordPress)
<?php
// rewrite /wp-content/themes/theme-name/css/ to /css/
// rewrite /wp-content/themes/theme-name/js/ to /js/
// rewrite /wp-content/themes/theme-name/img/ to /img/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
@federicosan
federicosan / gist:97d1d2e6077742390f760cdfe0402923
Created July 15, 2016 19:08 — forked from wycks/gist:2315279
Relative URLs in WordPress (hide wordpress)
<?php
function roots_root_relative_url($input) {
$output = preg_replace_callback(
'!(https?://[^/|"]+)([^"]+)?!',
create_function(
'$matches',
// if full URL is site_url, return a slash for relative root
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
// if domain is equal to site_url, then make URL relative
@federicosan
federicosan / _mixins.scss
Created June 12, 2016 04:42 — forked from danbettles/_mixins.scss
Sass mixin for Compass that vertically centres a descendant of the element in which it is included. The mixin neatly wraps-up Sebastian Ekström's updated solution in http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/
@import "compass/css3/transform";
@mixin vertically-centre-descendant($descendant-selector, $descendant-position: relative) {
@include transform-style(preserve-3d);
position: relative;
#{$descendant-selector} {
@include transform(translateY(-50%));
position: $descendant-position;
top: 50%;