This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add the Warden strategy contained in local_override.rb into the devise.rb file. The devise.rb should also be in the config/intializers directory. | |
Devise.setup do |config| | |
config.warden do |manager| | |
manager.default_strategies(:scope => :user).unshift :local_override | |
end | |
# Other devise configuration... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To make this server publicly available on the inter-webs while running from localhost, use ngrok, which can be found here: | |
# https://ngrok.com/download. Follow the installation instructions for ngrok and start it up: | |
# | |
# ./ngrok 4567 # (or whatever port you want to listen on). | |
# | |
# ngrok will spit out an ugly but unique URL. After ngrok starts up, you should be able to POST to the sinatra server: | |
# | |
# http://6eee766f.ngrok.com/payload | |
require 'sinatra' | |
require 'json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is something I ALWAYS forget about, so hopefully this Gist will serve as a reminder. Whenever you get the "Access-Control-Allow-Origin" | |
// error, that's because you're trying to make a cross-domain AJAX request, which is a big no-no in the world of the internet. | |
// So, after spending WAY more time than I care to admit trying to address this, I remembered that JSONP is the answer. Here's | |
// how to do it: | |
$.ajax({ | |
url: [/* whatever your URL is */], | |
/*type: 'GET',*/ // seems superfluous - .ajax uses GET by default. | |
dataType: 'jsonp', | |
/*crossDomain: true,*/ // seems to work fine without this. | |
data: { /* an object with whatever data you need to pass along in your JSONP request */ }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can paste this code into IDEone (http://ideone.com) and run it. For some reason, I can never remember how to do this. | |
// Therefore, I've made this Gist. There's probably a million smarter ways to handle this situation, but this one seems to | |
// work just fine. | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
public class Test | |
{ | |
public static void Main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def valid_json?(data) | |
JSON.parse(data) | |
return true | |
rescue JSON::ParserError | |
return false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<persistence xmlns="http://java.sun.com/xml/ns/persistence" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence_2_0.xsd" | |
version="2.0"> | |
<persistence-unit name="punit"></persistence-unit> | |
</persistence> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The command below will take a list of files in the current directory, sort them and cat them together into a single file. | |
# The files against which this command was initially used were all named using the following convention: | |
# | |
# V[some number]__[the name of the file].sql | |
cat `ls -1 *.sql | sort -k1.2n` > /tmp/migration.sql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"caret_style": "phase", | |
"color_scheme": "Packages/Base16 Color Schemes/base16-default.dark.tmTheme", | |
"fade_fold_buttons": false, | |
"font_face": "Source Code Pro", | |
"font_size": 12.0, | |
"highlight_line": true, | |
"ignored_packages": | |
[ | |
"Vintage" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Configure a Daily File Appender. | |
-- The datePattern param specifies how the date should appear in the file name. | |
-- The root element sets the log level for every logger that is configured in this file. | |
-- To override the log level for an individual logger, add a level element to the desired logger and set it to whatever you want. | |
-- Each class has its own logger. | |
-- The name of the logger matches the class exactly. | |
-- In PHP, this means we can create a logger like this (in a class's constructor, for example): | |
-- $logger = Logger::getInstance( __CLASS__ ); | |
--> | |
<configuration xmlns="http://logging.apache.org/log4php/"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Came from the second answer on here: http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git | |
# but writing it out myself helps get it through the metal plate in my head. | |
# | |
# Assumes the following situation: | |
# You have a feature branch that you're developing against, e.g. feature/diaper-horse. | |
# You have a remote branch origin/feature/diaper-horse. | |
# feature/diaper-horse is set up to track origin/feature/diaper-horse | |
# | |
# Let's say you have 8 commits total (of your own) for the branch feature/diaper-horse. | |
# Reset to x - 1, where x is the number of commits you're ahead of the remote branch. Like so: |