Skip to content

Instantly share code, notes, and snippets.

View adrianmarian's full-sized avatar
💭
I may be slow to respond.

Adrian Gadescu adrianmarian

💭
I may be slow to respond.
View GitHub Profile
@adrianmarian
adrianmarian / csv_export.rb
Created August 23, 2019 15:04 — forked from foxumon/csv_export.rb
Export table to CSV with all attributes in rails console
require 'csv'
file = "#{Rails.root}/public/data.csv"
table = User.all;0 # ";0" stops output. Change "User" to any model.
CSV.open( file, 'w' ) do |writer|
writer << table.first.attributes.map { |a,v| a }
table.each do |s|
writer << s.attributes.map { |a,v| v }
@adrianmarian
adrianmarian / Reset-BashPassword.ps1
Created December 1, 2018 11:35 — forked from richardszalay/Reset-BashPassword.ps1
Reset-BashPassword.ps1
# Resets the password for the default LXSS / WSL bash user, based on https://askubuntu.com/a/808425/697555
$lxssUsername = (Get-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss).DefaultUsername
lxrun /setdefaultuser root
bash -c "passwd $lxssUsername"
lxrun /setdefaultuser $lxssUsername
@adrianmarian
adrianmarian / partials.php
Created November 13, 2018 12:04 — forked from eric1234/partials.php
Similar to just calling "require" on a template but isolates the scope to just the variables provided. Also easier control over if the template should output directly or return the content.
<?php
# https://gist.github.com/eric1234/6357465
#
# Will render the given template passing on the given params as
# variables in that scope. For example:
#
# partial('hello.php', array('name' => 'Joe'))
#
# Then your template can have:
#
@adrianmarian
adrianmarian / .1 README.md
Created November 13, 2018 12:04 — forked from eric1234/.1 README.md
The Gist-based PHP framework.

Motivation

Writing apps today almost always starts with a framework. Systems such as Ruby on Rails, Django, etc are leading the pack in developing best of breed web frameworks for advanced web apps.

Attempts to copy this style of framework in PHP has largely failed. Systems such as CodeIgniter are buggy and more limited than their counterparts in other languages despite PHP having a much bigger community.

@adrianmarian
adrianmarian / vagrant_mailcatcher.sh
Created November 13, 2018 12:02 — forked from eric1234/vagrant_mailcatcher.sh
Installs Mailcatcher. Assumes Ruby (https://gist.github.com/eric1234/6642819) already installed.
sudo apt-get install -y libsqlite3-dev
gem install mailcatcher
rbenv rehash
cat <<EOF | sudo tee /etc/init/mailcatcher.conf
description "Test mail server"
start on runlevel [2345]
stop on runlevel [016]
respawn
@adrianmarian
adrianmarian / README.md
Created November 13, 2018 12:02 — forked from eric1234/README.md
Modified radio buttons so they are allowed to be unchecked

Include this script and all your radio buttons can be unchecked. The result is the radio box group goes back to a state where no radio is checked. Sort of a cross between a radio button and a checkbox. This means your backend should be prepared for that field to be empty even if you populated it when the page was loaded.

This script assumes it is operating in a Turbolinks environment as it initializes using the page:change event. If you are not using Turbolinks you will want to change it to use the jQuery ready event.

@adrianmarian
adrianmarian / Email Server (Linux, Unix, Mac).md
Created November 7, 2018 11:40 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only Email Server (Linux, Unix, Mac)

Setup a Local Only Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@adrianmarian
adrianmarian / postfix.php
Created November 5, 2018 14:13 — forked from jaysonrowe/postfix.php
Parse e-mail with PHP
#!/usr/bin/php -q
<?php
// get mail via stdin
$email = file_get_contents("php://stdin");
// handle email
$lines = explode("\n", $email);
// set empty vars and explode message to variables
@adrianmarian
adrianmarian / README-Template.md
Created October 30, 2018 17:21 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites