Skip to content

Instantly share code, notes, and snippets.

@LeaVerou
LeaVerou / dabblet.css
Created July 24, 2014 18:18
Image slider with pure CSS
/**
* Image slider with pure CSS
* Original version in http://demosthenes.info/blog/css
*/
.image-slider {
position:relative;
display: inline-block;
line-height: 0;
}
@bsweger
bsweger / useful_pandas_snippets.md
Last active June 14, 2025 19:01
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@mannieschumpert
mannieschumpert / gist:8886289
Last active August 2, 2020 13:15
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );
@gloriousgeneralist
gloriousgeneralist / gist:7223014
Last active December 26, 2015 22:29
Using jQuery for creating database outgoing links custom events. You obviously need to replace the 'a.db_name' with whatever class you wrap your database links in. If you are using this in Drupal, as I am, use instructions here to make your life easier when creating jQuery objects: https://drupal.org/node/171213#comment-4686396.
<!--Database custom events-->
<script type="text/javascript">
$(document).ready(function(){
$('a.db_name').each(function(){
var db_name = $(this).text();
$(this).click(function(){
_gaq.push(["_trackEvent", "linkOut", "database", db_name]); // create a custom event
});
});
});
@jamarparris
jamarparris / Generate Mongo Object ID in PostGres
Last active April 1, 2025 13:43
Create ObjectIds in PostGres following the MongoDB semantics. Very similar to the Instagram approach linked below.http://docs.mongodb.org/manual/reference/object-id/http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram
The MIT License (MIT)
Copyright (c) 2013 Jamar Parris
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S
@wrobstory
wrobstory / README.md
Last active December 17, 2015 05:38
Folium Markers with Lat/Lng Popovers

A custom Mapbox map generated by Folium. One fixed marker, one fixed circle marker. Click on the map to place a new marker, click the marker to see Lat/Lng, double-click the marker to remove it. This map was generated with the following Python code:

import folium

#Custom Mapbox Tiles
tileset = r'http://a.tiles.mapbox.com/v3/[...]/{z}/{x}/{y}.png'
attribution = (r'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a>'
                ' contributors, Imagery © <a href="http://mapbox.com">MapBox</a>')
#Create Map
mapbox = folium.Map(location=[45.5236, -122.6750], tiles=tileset, zoom_start=13,
@morganestes
morganestes / WordPress get_the_ID() replacement.md
Last active May 16, 2021 21:15
Get the WordPress post ID no matter where you are.

This extends the built-in WordPress function get_the_ID() to return the post ID both inside and outside the loop.

Used outside the loop (in header.php):

<?php if ( function_exists( 'gt_hide_nav' ) && ! gt_hide_nav() ) : ?>
  <nav role="navigation">
    <?php if ( function_exists( 'bones_main_nav' ) ) bones_main_nav(); ?>
  </nav>
@timss
timss / python-daemon_apscheduler.py
Last active April 4, 2020 04:50
A combination of python-daemon and APScheduler
#!/usr/bin/env python
import apscheduler.scheduler
import daemon.runner
import os.path
import sys
import time
class Core():
def __init__(self):
anonymous
anonymous / README.md
Created February 19, 2013 23:32
Created by Anonymous at BootTheme (http://www.boottheme.com)
@emiller42
emiller42 / gist:4982462
Last active October 17, 2022 19:00
Adding Tomcat to MAMP
1) Install MAMP normally
2) Download the latest binary of tomcat from http://tomcat.apache.org/ and extract it into the MAMP folder
(you should now have a /Applications/MAMP/apache-tomcat-version folder)
3) Create a link to the apache-tomcat folder:
ln -s /Applications/apache-tomcat-7.0.37/ tomcat
4) Make sure all the binaries are executable:
cd /Applications/tomcat/bin