Skip to content

Instantly share code, notes, and snippets.

@hilja
hilja / create-mysql-db.sh
Last active August 17, 2020 06:21
Shell script to create MySQL database and user
#!/bin/bash
# Functions
ok() { echo -e '\e[32m'$1'\e[m'; } # Green
EXPECTED_ARGS=3
E_BADARGS=65
MYSQL=`which mysql`
Q1="CREATE DATABASE IF NOT EXISTS $1;"
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@tarnacious
tarnacious / search.cs
Created November 28, 2011 06:47
Searching for multiple terms using the Umbraco Examine API.
// This seems way too difficult for what you would expect to be a pretty common task;
// taking a search string from the user and finding documents which contain some or all of the terms
// in the search string.
// This function naively splits a search string into terms and finds documents
// which contain some or all of the terms. Does not handle quoted terms as or ignore case as it should.
public IEnumerable<SearchResult> Search(string searchString, string[] fields)
{
// Spit the search string and return an empty list if no search string was provided.
if (string.IsNullOrEmpty(searchString)) return new List<SearchResult>();