Skip to content

Instantly share code, notes, and snippets.

@markgx
markgx / ecto_to_sql.ex
Created January 31, 2019 02:01 — forked from DanielBlanco/ecto_to_sql.ex
How to output Ecto's generated SQL to console.
{sql, _} = Repo.to_sql(:all, query)
IO.puts sql
@markgx
markgx / mac-static-host.md
Created June 16, 2018 22:20
Quickly serve a folder on your Mac

If you need to quickly host a static HTTP site from your Mac for testing or other purposes, run the following commands.

$ cd /path/to/local/static/site
$ python -m SimpleHTTPServer 8000

Keybase proof

I hereby claim:

  • I am markgx on github.
  • I am markgx (https://keybase.io/markgx) on keybase.
  • I have a public key ASCxHtsTeoqtnDjDJiRezqBe1yCB64LYWQjp2IbIMBMKngo

To claim this, I am signing this object:

@markgx
markgx / cmd prompt.sh
Last active May 13, 2016 22:28
custom bash prompt
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
echo "[${BRANCH}] "
fi
}
PS1="⚡️ \w \[\e[32m\]\`parse_git_branch\`\[\e[m\]\[\e[33m\]\u\[\e[m\]$ "
var DropDownListOption = React.createClass({
render: function() {
return (
<option value={this.props.value}>{this.props.text}</option>
);
}
});
var DropDownList = React.createClass({
getDefaultProps: function() {

Keybase proof

I hereby claim:

  • I am markgx on github.
  • I am markgx (https://keybase.io/markgx) on keybase.
  • I have a public key whose fingerprint is 602C 884A 8B4A F154 BD39 A939 32C2 E546 048F 4CFC

To claim this, I am signing this object:

Homebrew cheatsheet

List installed packages

$ brew list

List outdated packages

$ brew outdated

@markgx
markgx / BaseRepository.cs
Created January 30, 2014 22:43
Base repository to derive from if using repository pattern with Entity Framework
using System.Data.Entity;
using System.Linq;
namespace SurveyTool.Models.Repositories
{
public class BaseRepository<T> where T : class
{
public SurveyToolEntities Context { get; set; }
public BaseRepository()

Git Cheatsheet

Diff current branch and master

$ git diff master

Diff staged changes

$ git diff --cached
using System;
using System.Drawing;
namespace SurveyTool.Helpers
{
public static class ImageHelper
{
public static Image ScaleImage(Image image, int maxWidth, int maxHeight)
{
// credit: http://stackoverflow.com/a/6501997/8357