Skip to content

Instantly share code, notes, and snippets.

@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@ak64th
ak64th / app.py
Created December 25, 2015 09:40
Hello world for flask assets and underscore templates
from flask import Flask, render_template
from flask_assets import Bundle, Environment
app = Flask('app')
app.config['JST_COMPILER'] = u'_.template'
app.config['JST_NAMESPACE'] = 'window.Templates'
app.config['JST_BARE'] = False
env = Environment()
import requests
zips = "59221, 73949, 86515, 42223, 86044, 84536, 97635, 02861, 71749, 81137, 63673, 88063, 89439".split(', ')
url = 'https://congress.api.sunlightfoundation.com/districts/locate?apikey=4356d7e2b68340a69fb9b5e156e9cd49&zip='
for z in zips:
r = requests.get(url + z).json()['results']
print z, r
@grantmcconnaughey
grantmcconnaughey / pdf.py
Last active February 8, 2021 21:50 — forked from zyegfryed/pdf.py
Outputting PDFs with Django 1.8 and FDFgen
# -*- coding: utf-8 -*-
import codecs
import subprocess
from fdfgen import forge_fdf
from django.core.exceptions import ImproperlyConfigured
from django.template import engines
from django.template.backends.base import BaseEngine
from django.template.engine import Engine, _dirs_undefined
@p3t3r67x0
p3t3r67x0 / pseudo_elements.md
Last active January 16, 2024 01:17
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@salsalabs
salsalabs / disable_welcome_back.html
Last active December 19, 2018 20:45
A script to disable Salsa's welcome back message. The supporter is logged out of the current page and returned to the same page. A flag is placed into session storage that this script doesn't loop forever. The script ignores pages that are part of a workflow or that have a displayed error.
<script type="text/javascript">
// Automatically log supporters out of Salsa pages, effectively disabling the
// Welcome Back Message. See https://help.salsalabs.com/hc/en-us/articles/223344487
// This script will not run if Salsa's returned an error.
if (document.querySelector('.error') == null) {
if (typeof window.sessionStorage.redirected == "string") {
delete window.sessionStorage.redirected;
} else {
var notThese = ['event/common.+checkout.sjs', 'guestReg', 'receipt.sjs',
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@impressiver
impressiver / raven-config.html
Last active February 27, 2024 14:27
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',
@tmcw
tmcw / index.html
Created November 13, 2012 18:58
double click and single click separation
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
body { margin:0; padding:0; }
#map { width:960px; height:500px; background:cyan; }
</style>
</head>
<body>
@malarkey
malarkey / Contract Killer 3.md
Last active May 13, 2024 13:18
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………