Skip to content

Instantly share code, notes, and snippets.

// Use wp-config-local.php for local server settings, don't check that file onto the server
if ( file_exists( dirname( __FILE__ ) . '/wp-config-local.php' ) ) {
include( dirname( __FILE__ ) . '/wp-config-local.php' );
// Otherwise use the below settings (on live server)
} else {
// Live Server Database Settings
define( 'DB_NAME', 'db_name');
define( 'DB_USER', 'db_username');
@ralphking
ralphking / Authorization_helper.rb
Created February 10, 2015 10:48
Persisting guests users in devise.
module AuthorizationHelper
# if user is logged in, return current_user, else return guest_user
def current_or_guest_user
if current_user
if cookies.signed[:guest_user_id]
logging_in
guest_user.delete
cookies.delete :guest_user_id
end
@ralphking
ralphking / js_chess
Created February 18, 2015 11:05
JS chess board. Useful for two dimensional loops
// set your board size
var size = "64";
// initialize empty string
var string = "";
// loop the sucker
for (var i = 0; i < size; i++) {
for (var j = 0; j < size; j++) {
if ((i + j) % 2 == 0) {
string += " ";
} else {
@ralphking
ralphking / views.py
Created April 22, 2015 09:48
Django
@login_required()
@permission_required('venue.add_space', raise_exception=True)
def new_space(request, venue_id):
venue = Venue.objects.get(id = venue_id)
if not venue.owner == request.user:
return HttpResponseForbidden()
else:
context = {'form': SpaceForm, 'venue': venue}
if request.method == 'POST':
@ralphking
ralphking / Pageload.py
Last active March 28, 2019 11:51
Django search
class SearchView(FormMixin, ListView):
template_name = 'search.html'
context_object_name = 'spaces'
form_class = SearchForm
def get_initial(self):
'''get initial values from request params'''
if self.request.GET:
initial = self.request.GET.dict()
return initial

Keybase proof

I hereby claim:

  • I am ralphking on github.
  • I am ralphking (https://keybase.io/ralphking) on keybase.
  • I have a public key ASD1pCpcvfNvryMiYP_ov_6b3kZKR-D_V-yKhlIJS4waago

To claim this, I am signing this object:

Vue Js gists to save time starting a new project

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->