Skip to content

Instantly share code, notes, and snippets.

View eiriksm's full-sized avatar
💭
I may be slow to respond.

Eirik Stanghelle Morland eiriksm

💭
I may be slow to respond.
  • Frontkom / Violinist.io
  • Trondheim, Norway
  • 04:29 (UTC +02:00)
  • X @orkj
View GitHub Profile
{
"extra": {
"violinist": {
"bundled_packages": {
"drupal/core-recommended": [
"drupal/core-composer-scaffold"
]
},
"blacklist": [
"drupal/core-composer-scaffold"
@eiriksm
eiriksm / outtakes.vcl
Created November 26, 2014 17:02
outtakes.vcl
sub vcl_recv {
# ... some other stuff and logic.
# This is so special I keep it in a separate if block.
if (req.http.host == "orkjern.com") {
# These first lines are based on lullabot's setup. Google it.
set req.http.Cookie = ";" + req.http.Cookie;
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
# This cookie gets set from javascript.
if (req.http.Cookie ~ "ORKJERN_THEME_CACHE") {
@eiriksm
eiriksm / cam.js
Created November 2, 2014 15:38
phonegap camera drupal js
$("#someid").click(function() {
navigator.camera.getPicture(picsuccess, onfail, { quality: 50 });
});
function picsuccess (data) {
url = "http://example.com/endpoint"; // Your services endpoint
var data = {
"file": data,
"filename": "test.jpg"
};
drupalServicesPostFile(data, url, postwith);
@eiriksm
eiriksm / js2.js
Created November 2, 2014 15:37
js phonegap drupal
$("#someid").click(function() {
var data = "R0lGODlhSABIAOZ/ANtwcLu6uvXY2M/NzdNQUP76Av55Bf2PBeZHBtgtCPz09GwxMf3QBPf3lzgrK/HJye25uY2MjP39X8EBAVIwMPttBoIqK//+/qloaJGMGHJvbeSamuikpL4AAfrr62BeEt+Bgf2tBA8MC8kmJvj0OMYUFcQJCuGJiZtcFujo55kWF5WUY/34+Mw1NswVCPjj4//o2EFBGfzrAkdGRfHx8aYFBSMcHNC8r+52NKs2NcO9LN1NLbaFhMEECPDBwHZ0Pd45Bv78FHpEQcxYAs87OMMHCLE1BOjlAkcFBvfg4P//1Nzb29plDuFbLtEfBvTU0sR7MZAqBL4ZFVIiCvbsG/no59g/IMkMAuyFOHgGBsuJAv//+MUNDaAODulsB//69s0xLv77+/PPz915eeuyssorLKkeHsgQCmg9BrsPDdZcXNhkZOOSksgeHpAhIcQFAqeko+1WCOtyBu19HvRiB/bd3f2BHPvw8DAvENBCQviiJOqsq9zaB7MQDgAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJCgB/ACwAAAAASABIAAAH/4B/goOEhYaFCoMXgw9jAoeQkZKTkYuEDxCGbGMehwp3lKGih2GESW2PhGwAloYPiaOxoQKggmEEHVWEPkSwhmF7rR53F6Wyx39ia74CE0Wpfwp5PpUbixcbBAoAtcijDyPUjBNnmYJkea2HZLoQHWwcXMbeoQotAIU+EyUcg2pjk5JYG9NBDIEJL+iJetDhSSEPBx8IUlBmwyQWIARsyFOlxARzCif5MMFC0B1jJ1rA8mDC4iQOJ8QIYHHQh5iSISPVKVFrg8M/EMgM8jDhhKBihhI9yINzo6Ocki6cWPOAw4g9gli0UmBizSIFIAVh+iOgCCwQBDol7ZZTAcEJE//6GbqgxkSiMCBanXr0wESnVfMKvYI6KAyACWASHtrQASsvYwJw6eLQoQ4
var date = new Date();
var timestamp = Math.round(date.getTime() / 1000);
var node_object = {
"type": prompt("Enter content type"),
"title": prompt("Enter node title"),
"body": {
"und": [
{"value": prompt("Enter body text"); }
]
},
@eiriksm
eiriksm / tpl.php
Created November 2, 2014 15:23
First style hack
<?php
print '<style>';
$style = ''
foreach ($css as $c) {
// Do some checking of some media query stuff.
// ...
// Then store the raw CSS.
$style .= file_get_contents($c['data']);
}
//do some regex to remove some stuff, and remove whitespace.
@eiriksm
eiriksm / my_module.module
Created November 2, 2014 15:14
Fixing descriptions
<?php
/**
* Implements hook_webform_component_presave().
*/
function mymodule_webform_component_presave(&$component) {
// Maybe I should do some more robust checking here, but this is a simple site
// and the body description clearly states how to format lines with links.
// Also, remember if you have other use cases for the webform, you should
// check that this is actually a webform created by above code!
if (strpos($component['name'], '(http') > -1) {
@eiriksm
eiriksm / my_module.module
Created November 2, 2014 15:12
Programatically creating webforms
<?php
/**
* Implements hook_node_insert().
*/
function mymodule_node_insert($node) {
// The node type I am using is called 'order'.
if ($node->type == 'order') {
// I am using the body field for values.
$body = field_get_items('node', $node, 'body');
$comp = explode("\n", $body[0]['value']);
@eiriksm
eiriksm / my_module.module
Created November 2, 2014 15:08
environment check
<?php
if (variable_get('environment', '') == 'development') {
return;
}
@eiriksm
eiriksm / html.tpl.php
Created November 2, 2014 15:01
template print
<?php
print client_cache_styles($css);
print client_cache_scripts($scripts);