Skip to content

Instantly share code, notes, and snippets.

View ranelpadon's full-sized avatar

ranelpadon

View GitHub Profile
@jacobbednarz
jacobbednarz / drupal_write_record_example.php
Last active December 30, 2015 04:29
Example of using drupal_write_record over a conditional db_insert and db_update.
<?php
// Let's say for argument sake $query is a database query that checks for the
// presence of an existing record and returns FALSE if nothing is found. In this
// example, we need to check for an existing record and update the row if it
// exists or create a new entry if it doesn't.
/**
* Bad
*/
@becw
becw / example.install.php
Last active March 26, 2019 06:53
Enable/revert a feature in a Drupal update hook #drupal7
/**
* EXAMPLE FEATURE UPDATE
* Enable and revert the my_new_feature_name feature.
*/
function example_update_7001() {
// An array of new or changed features; the array keys are feature names,
// values are an array of exportable types as seen in a feature's .info file:
// features[field][] = node-page-body
$features = array(
'my_new_feature_name' => array('field', 'variable'),
@JustAdam
JustAdam / drupal_taxonomy_content_type.php
Created August 2, 2012 09:49
Drupal 7 - Programmatically create a taxonomy and attach a field to it, then create a content type and attach that taxonomy to it.
<?php
// Machine name for our custom node
define('NODE_NAME', 'the_node_machine_name');
// Machine name for our custom taxonomy
define('TAXONOMY_NAME', 'the_taxonomy_machine_name');
function module_install() {
_create_taxonomy();
_create_content_type();
}
@brianwitte
brianwitte / doom.txt
Created July 30, 2020 05:55 — forked from hjertnes/doom.txt
Doom Emacs Cheatsheet
SPC
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
@anandkkpr
anandkkpr / _osx-10.11_postfix-php-drupal.md
Last active September 30, 2020 19:44
Postfix+PHP+Drupal on OSX 10.11.11 (El Capitan) for Software Developers (a.k.a software development and testing).

How to get mail sending to work on OSX for development purposes ONLY.

OSX comes with Postfix pre-installed. All that needs to be done is to configure it AND PHP. There are a couple of configuration files involved. Each file that needs to be adjusted is attached to this gist along with the relevant configuration options and settings.

You will start by editing the Postfix config file located at: /private/etc/postfix/main.cf. You will then edit your PHP config file (php.ini) which, for me I installed via macports and was thus located at: /opt/local/etc/php56/php.ini.

These are the two pages that I used to get things working:

  1. How to send emails from localhost (MAC OS X El Capitan)
@kaushikgopal
kaushikgopal / karabiner.json
Last active January 11, 2021 17:40
Karabiner.json generated using Goku. For source edn file see https://gist.github.com/kaushikgopal/ff7a92bbc887e59699c804b59074a126
{
"global" : {
"check_for_updates_on_startup" : true,
"show_in_menu_bar" : true,
"show_profile_name_in_menu_bar" : false
},
"profiles" : [ {
"complex_modifications" : {
"parameters" : {
"basic.simultaneous_threshold_milliseconds" : 50,
@ravidsrk
ravidsrk / Install.md
Last active September 30, 2021 15:46
Deploying django application with gunicorn nginx mysql

Step One: Update Packages

sudo apt-get update
sudo apt-get upgrade

Step Two: Install and Create Virtualenv

sudo apt-get install python-virtualenv
sudo virtualenv /opt/myenv
@larrybotha
larrybotha / readme.markdown
Last active October 27, 2021 04:28
Postfix Using Gmail SMTP in Mac OSX Mavericks
@rctay
rctay / gist:527113
Created August 16, 2010 15:18
[django] check if db table exists
"""
Came up with this for satchmo's downloadable product migration, 0001_split.
"""
def db_table_exists(table, cursor=None):
try:
if not cursor:
from django.db import connection
cursor = connection.cursor()
if not cursor:
raise Exception
@riklomas
riklomas / adding-to-user-admin-form.py
Created August 6, 2010 15:01
How to add a field to the Django Admin Add User form using UserCreationForm. Add this to a admin.py and alter to whatever fields you'd like
# How to add a field to the Django Admin Add User form
# using UserCreationForm. Add this to a admin.py and alter
# to whatever fields you'd like
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin