Skip to content

Instantly share code, notes, and snippets.

@destroytoday
destroytoday / gist:707232
Created November 19, 2010 21:36
Returns unique timestamps rounded down to the date (SQLite)
SELECT DISTINCT (round(timestamp / 86400000.0 - 0.5) * 86400000.0) as time FROM timeline ORDER BY timestamp ASC
--in AIR, set itemClass to Date
--the returned dates are offset with the computer's timezone, so you need to reverse it: date.time += date.timezoneOffset * 60000;
@monperrus
monperrus / JettyServer.java
Created June 10, 2011 11:25
Running a standalone HTTP server with Jetty
import java.util.ArrayList;
import java.util.List;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;
@tawman
tawman / Index.cshtml
Created February 19, 2012 01:51
PetaPocoPage View with a Table and DataTables Configuration
@{
ViewBag.Title = "Server-Side Paging with PetaPoco DataTables";
}
<table id="customers" class="table table-striped table-condensed">
<thead>
<tr>
<th style='width: 4%'>Id</th>
<th>Last</th>
<th>First</th>
@wrburgess
wrburgess / gist:5528649
Last active September 13, 2024 19:00
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production

@halcarleton
halcarleton / SublimeText-Project-Line-Count
Last active August 6, 2023 16:09 — forked from Hexodus/count_total_project_code_lines_in_sublime
Count total lines of code in a Sublime Text Project or Directory
Go to menu:
Find -> Find in Files... (windows: ctrl+shift+f)
Switch on reg_ex button (windows: alt+r)
Find:
^.*\S+.*$
Where:
c:\your_folder\,*.php,*.js,*.inc,*.html,*.htm,*.scss, -*/folder_to_exclude/*, -*.min.js
# for use by collection_select and friends, to link a human-readable label with a db-friendly symbolic value
# todo: ActiveRecord macros for setters (for allowing multiple values or just one)
# Usage:
# Table name: snacks
# id :integer
# ice_cream :string
# class Snack < ActiveRecord::Base
# FLAVORS = Enum.new [
# [:vanilla, "Vanilla"],
# [:chocolate, "Chocolate"],
@nickbabcock
nickbabcock / DropRawApplication.java
Last active March 8, 2019 06:50
Dropwizard Example using Raw Jetty
package com.example;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.google.common.base.Strings;
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
import org.eclipse.jetty.servlet.ServletHolder;
import javax.servlet.ServletException;