Skip to content

Instantly share code, notes, and snippets.

@clouddueling
clouddueling / fulltext.sql
Created November 12, 2012 18:38
How to create a fulltext index
ALTER TABLE `contacts` ADD FULLTEXT `search` (`first`,`last`,`email`);
@clouddueling
clouddueling / addFulltextIndex.sql
Created November 12, 2012 18:40
How to add to a fulltext index
CREATE FULLTEXT INDEX `contacts` ON `search` (`first`, `last`, `email`, `phone`);
@clouddueling
clouddueling / somecontroller.php
Created November 13, 2012 17:34
Using Eloquent with Javascript
function get_card($card_id)
{
$card = Card::find($card_id);
$data = array(
'json_card' => json_encode($card),
);
$this->layout->nest( 'content', 'card.form_editor', $data );
}
@clouddueling
clouddueling / gist:4072853
Created November 14, 2012 15:42
Permission denied crontab
// Check your crontab
crontab -l
// Edit your crontab and set MAILTO=myemail@email.com
crontab -e
// Getting permission denied on the bash you're trying to run?
chmod -c 777 backupSql.sh
// Change your crontab to run one minute in the future
@clouddueling
clouddueling / modulePattern.js
Created November 14, 2012 15:57
Javascript: The Module Pattern
// Source: http://javascriptweblog.wordpress.com/2010/12/07/namespacing-in-javascript/
var myApp = (function() {
var id= 0;
return {
next: function() {
return id++;
},
@clouddueling
clouddueling / fulltextsearch.php
Last active May 17, 2017 21:42
Fulltext eloquent search with Laravel
public static function read_search($terms, $limit = 20)
{
$contact_results = Contact::where_account_user_id(Auth::user()->account_user_id)
->where_deleted(0)
->where_marketing(0)
->where_mass_merge(0)
->raw_where("match (`first`, `last`) against (?)", array($terms))
->take($limit)
->get();
@clouddueling
clouddueling / is_64_bit.php
Created December 9, 2012 18:45
Is my php server 64 bit?
<?php
// http://ideone.com/JWKIf
function is_64bit() {
$int = "9223372036854775807";
$int = intval($int);
if ($int == 9223372036854775807) {
/* 64bit */
return true;
@clouddueling
clouddueling / quiz_writer.php
Created December 9, 2012 22:58
How to write user generated quizzes
<?php
$users = User::all();
foreach ($users as {{4}}) {
$user{{2}}name;
}
?>
/*
@clouddueling
clouddueling / index.html
Created December 16, 2012 00:19
A CodePen by Dave Rupert.
<h1>dataCodeBlock, an automagical code block generator</h1>
<p>When documenting style guides, maintaining parity between your "living" demos and code samples can be a pain in the butt. dataCodeBlock automates that.</p>
<h2>Demo</h2>
<ul data-codeblock="#target-div">
<li>This <code>UL</code> uses the <code>data-codeblock</code> attribute</li>
<li>It targets the <code>#target-div</code> selector and appends there.</li>
<li>The output generated code block removes the attribute.</li>
</ul>
/*
Note the white space in the $page variable.
$page is set somewhere up here and is being concatenated upon.
These units are in bytes.
Sourced from: http://stackoverflow.com/questions/2192657/how-to-determine-the-memory-footprint-size-of-a-variable
*/
// WITHOUT WHITE SPACE: http://screencloud.net/img/screenshots/e5c9b31c4b20021082c22a551fca903c.png
$start_memory = memory_get_usage();