Skip to content

Instantly share code, notes, and snippets.

View faulker's full-sized avatar

Winter Faulk faulker

  • Clearwater Analytics
  • Boise, ID
View GitHub Profile

Keybase proof

I hereby claim:

  • I am faulker on github.
  • I am faulker (https://keybase.io/faulker) on keybase.
  • I have a public key whose fingerprint is E109 0BC0 E464 5715 39EC DD9C 5756 1F0C D864 9D84

To claim this, I am signing this object:

-- Delete all duplicate entries that match 'PARTITION BY' section and are 'completed' and 'finished_at' falls between timestamps
DELETE FROM edge_scores AS a
WHERE a.id IN (
SELECT id
FROM (
SELECT
id,
ROW_NUMBER()
OVER (
PARTITION BY user_id, assignment_id, finished_at::DATE, asset_id, score, completed
@faulker
faulker / update_json.sql
Created October 27, 2016 18:40
Example of how to update a Postgresql JSON field using jsonb_set
update tests_summary_data set data = (jsonb_set(to_jsonb(data), '{misc,gap,pa}', '-1', false))::json where data->'misc'->'gap'->>'pa' = '0';
@faulker
faulker / json_in-array.sql
Last active May 23, 2017 17:02
Sql Tricks/Hacks/Examples
-- Checks to see if 'prealgebra' exists int he json array data->'series'
SELECT * FROM table WHERE jsonb_exists(data -> 'series', 'prealgebra');
@faulker
faulker / laravel on shared hosting
Last active August 10, 2016 06:32
Getting Laravel to work on Shared hosting
* create .htaccess file and put the fallowing in it
RewriteBase /
RewriteCond %{HTTP_HOST} !^subdomain
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
RewriteCond %{HTTP_HOST} ^subdomain
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/ [L]
@faulker
faulker / listenForSqlAndDisplay
Created May 28, 2015 22:43
Laravel DB Debug
function listenForSqlAndDisplay()
{
\DB::listen(function($sql, $bindings)
{
foreach ($bindings as $val) {
$sql = preg_replace('/\?/', "'{$val}'", $sql, 1);
}
var_dump($sql);
});
@faulker
faulker / sequence-analyzing.php
Last active December 18, 2015 05:29
Analyzes an array of date/time stamps to try and make a "best" guess on when the next date/time stamp will be.
function get_average($time_array)
{
$total = "";
$last = "";
$count = count($time_array);
for($t=0;$t<$count;$t++)
{
$time = $time_array[$t];
if($t == 0)
{