Skip to content

Instantly share code, notes, and snippets.

@tarnus
tarnus / gist:c46545ccded3520a62b3
Created June 5, 2014 16:35
Jquery to populate link locations
(function ($) {
Drupal.behaviors.appointment = {
attach: function(context, settings) {
//Begin my code
function arrayContains(needle, arrhaystack)
{
return (arrhaystack.indexOf(needle) > -1);
}
var statelist=new Array();
@tarnus
tarnus / gist:f5361d7f26a3e5201c56
Created June 6, 2014 16:45
Updated json cixx
var data2= new Array();
var items= new Array();
$.ajax({
dataType: "jsonp",
cache: true,
url: 'http://api.wunderground.com/api/c901ba8827136492/history_20000405/q/CA/San_Francisco.json',
data: data2,
success: function(data2){ // do something here
@tarnus
tarnus / godaddy_stuff
Created July 21, 2014 17:19
Godaddy Settings for Drush and php.ini
.drush/drush.ini:
memory_limit = 128M
error_reporting = E_ALL | E_NOTICE | E_STRICT
display_errors = stderr
in html folder file name php5.ini:
expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
/**
* @param $obj
* @param $field
* @param $value
*
* @return bool|null
*/
function searchJson($obj, $field, $value) {
$item=NULL;
foreach($obj as $struct) {
@tarnus
tarnus / gist:dfb11b78fc64a1fddf25
Created December 19, 2015 17:05
drupal 8 form alter submit handler
function mymodule_form_node_form_alter(&$form, FormStateInterface $form_state) {
// For entity builders.
kint($form['#form_id']);
if($form['#form_id'] == 'node_page_edit_form') {
foreach (array_keys($form['actions']) as $action) {
if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
$form['actions'][$action]['#submit'][] = 'mymodule_node_form_submit';
}
}
}
@tarnus
tarnus / ivchange.txt
Created July 22, 2020 00:03
IV CHange Column
def IV = Imp_Volatility();
def R = ((IV / IV[1]) - 1);
AddLabel(1, AsPercent(R), if R > R[1] then Color.Green else Color.Red);
@tarnus
tarnus / earnings.txt
Created July 22, 2020 00:03
Days to Earnings Column
#################
# ER Labels
#################
def daysBefore = 100;
def erInDays = AbsValue(GetEventOffset(Events.EARNINGS, 0));
def before = Sum(HasEarnings(), daysBefore)[-daysBefore];
AddLabel(Yes, IF before THEN "ER: "+erInDays+" days" ELSE "ER: No", IF before THEN Color.RED ELSE Color.GREEN);
@tarnus
tarnus / ip_address.txt
Created July 24, 2020 21:06
IP Address PHP funtion
function getUserIP() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
@tarnus
tarnus / luvnotes.module
Created July 27, 2020 21:15
Attache library to all pages
function luvnotes_custom_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = 'luvnotes_custom/luvnotes_custom';
}
@tarnus
tarnus / .lando.yml
Created August 14, 2020 20:17
d8 lando
name: d8dev
recipe: drupal8
config:
php: '7.3'
via: nginx
webroot: web
database: mariadb:10.3
xdebug: false
tooling: