Skip to content

Instantly share code, notes, and snippets.

View acao's full-sized avatar
👀

Rikki Schulte acao

👀
View GitHub Profile
@acao
acao / users_controller.js
Created May 14, 2012 21:13
RailwayJS Sample Users controller file
var bcrypt = require('bcrypt');
load('application');
before(loadUser, {only: ['show', 'edit', 'update', 'destroy']});
before(loadGroups, {only: ['new', 'edit']});
action('new', function () {
this.title = 'New user';
this.user = new User;
@acao
acao / commerce_feeds_example.make
Created June 15, 2012 20:58
Cleveland Drupal Users Group - Site Migration Workshop - Commerce Feeds Example
core = 7.x
api = 2
projects[drupal][version] = "7.x"
projects[admin_menu][version] = "3.0-rc3"
projects[ctools][version] = "1.0"
projects[commerce][version] = "1.3"
@acao
acao / Drupal7 User Autocomplete Entityreference Display
Created November 4, 2013 02:40
This is an example of creating an entityreference autocomplete display using views.
$view = new view();
$view->name = 'user_autocomplete_example';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'users';
$view->human_name = 'User Autocomplete Example';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
<?php
function get_orders($user){
$query = new EntityFieldQuery();
$query->entityCondition('entity_type','commerce_order');
$query->entityCondition('bundle', 'commerce_order');
$query->propertyCondition('user','uid',$user,'=');
$results = $query->execute['commerce_order'];
if ($results){
return $results;
@acao
acao / drupal_form_hide_nonrequired_fields
Last active August 29, 2015 14:02
A handy example of how to hide non-required fields from a form - in this case, on a profile2_regpath altered user_register_form
<?php
function MYMODULE_form_alter(&$form, &$form_state, $form_id){
if ($form_id == 'user_register_form') {
$fields = array_filter($form['profile_PROFILE_TYPE_NAME'], "_filter_required_fields");
foreach ($fields as $field_name => $field) {
$form['profile_PROFILE_TYPE_NAME'][$field_name]['und']['#access'] = false;
}
}
}
/**
* Implements hook_node_accces().
*/
function example_schedules_node_access($node, $op, $account) {
if ($op !== 'view' && $node->type == 'class') {
if($profile = example_account_profile($account->uid)){
if ($profile->type == 'teacher') {
if ($op == 'create'){
return NODE_ACCESS_ALLOW;
}
<?php
function example_update_N(){
// This manually enables the module using the same function features will use in the other example
features_module_enable('backup_migrate');
// Now you don't need to revert dependencies component because you've already enabled the module that you added.
$features['site_config'] = array('variable');
$features_rebuild($features);
$features_revert($features);
@acao
acao / queueexample.php
Created September 12, 2014 21:53
Queue Example
<?php
/**
* Implements hook_drush_command()
* goes in modulename.drush.inc
*/
function yogatrail_schedules_drush_command() {
$items = array();
$items['yt-schedules-update-classes'] = array();
<pre style="display:inline-block;text-align:center;font-family:monospace;letter-spacing:6.5px;line-height:13px;font-size:13px;font-weight:bold;">
<span style="color:rgb(127, 127, 127);">C</span><span style="color:rgb(236, 236, 236);">a</span><span style="color:rgb(254, 254, 254);">n</span><span style="color:rgb(254, 254, 254);">'</span><span style="color:rgb(254, 254, 254);">t</span><span style="color:rgb(255, 255, 255);">&nbsp;</span><span style="color:rgb(254, 254, 254);">f</span><span style="color:rgb(254, 254, 254);">u</span><span style="color:rgb(254, 254, 254);">c</span><span style="color:rgb(254, 254, 254);">k</span><span style="color:rgb(254, 254, 254);">&nbsp;</span><span style="color:rgb(254, 254, 254);">w</span><span style="color:rgb(254, 254, 254);">i</span><span style="color:rgb(254, 254, 254);">t</span><span style="color:rgb(254, 254, 254);">h</span><span style="color:rgb(255, 255, 255);">&nbsp;</span><span style="color:rgb(254, 254, 254);">t</span><span style="color:rgb(254, 254, 254);">h</span
@acao
acao / webpack.config.js
Last active January 12, 2022 17:30
Webpack example for electron and web
/* eslint strict: 0 */
'use strict';
const path = require('path');
const webpack = require('webpack');
const webpackTargetElectronRenderer = require('webpack-target-electron-renderer');
var argv = require('minimist')(process.argv.slice(2));
const isWeb = (argv && argv.target === 'web');
const output = (isWeb ? 'build/web' : 'build/electron');