Skip to content

Instantly share code, notes, and snippets.

View DriesS's full-sized avatar

Dries Steenhouwer DriesS

View GitHub Profile
@DriesS
DriesS / subscribe.rb
Created February 4, 2016 13:37
Method
def subscribe(id, email, merge_vars=nil, email_type='html', double_optin=true, update_existing=false, replace_interests=true, send_welcome=false)
_params = {:id => id, :email => email, :merge_vars => merge_vars, :email_type => email_type, :double_optin => double_optin, :update_existing => update_existing, :replace_interests => replace_interests, :send_welcome => send_welcome}
return @master.call 'lists/subscribe', _params
end
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
updateUser: function(){
const flashMessages = Ember.get(this, 'flashMessages');
this.get('model').save().then(function(){
flashMessages.success('Your profile was saved correctly!');
}, function(response) {
flashMessages.danger('Something went wrong!');
@DriesS
DriesS / interfaces
Created April 7, 2015 07:44
/etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.1.2.3
netmask 255.255.255.0
gateway 10.1.2.1
@DriesS
DriesS / Validation.php
Created March 24, 2015 09:35
Code vat check
/**
* Custom validation for the customer_profile_billing checkout pane.
*/
function arkaos_glue_commerce_checkout_form_validate($form, &$form_state, $checkout_pane, $order) {
$valid = TRUE;
// check vat
$vat = $form_state['values']['customer_profile_company_info']['field_vat_number']['und'][0]['vat_number'];
$country = $form_state['values']['customer_profile_billing']['commerce_customer_address']['und'][0]['country'];
@DriesS
DriesS / user.py
Created October 24, 2014 12:44
user.py
from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func
from sqlalchemy.orm import relationship, backref
from sqlalchemy.ext.declarative import declarative_base
import os
import sys
Base = declarative_base()
from falcon_mvc.database import db_session
@DriesS
DriesS / product.rb
Created August 4, 2014 12:06
Cache problem
class Product < StatisticsModel
has_one :active_sale, :class_name => 'Sale', :foreign_key => 'product_id', :conditions => ["sales.start_date <= ? AND (sales.end_date IS NULL OR sales.end_date > ?)", Time.zone.now, Time.zone.now], :order => "sales.start_date desc"
end
def top_menu_cache_key
rounded_time = Time.zone.now.round(30.minutes)
if Rails.cache.fetch('top_menu_cache_key').nil? || rounded_time != Rails.cache.fetch("rounded_time")
debugger
Rails.cache.write('top_menu_cache_key', "top_menu:#{Product.active.on_sale.maximum(:updated_at)}")
Rails.cache.write('rounded_time', rounded_time)
end
return Rails.cache.fetch('top_menu_cache_key')
end
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-====================================-====================================-========================================================================================
ii acpi 1.5-2 displays information on ACPI devices
ii adduser 3.112+nmu2 add and remove users and groups
ii apache2 2.2.16-6+squeeze11 Apache HTTP Server metapackage
ii apache2-mpm-prefork 2.2.16-6+squeeze11 Apache HTTP Server - traditional non-threaded model
ii apache2-utils 2.2.16-6+squeeze11 utility programs for webservers
$result = [serial] => stdClass Object
(
[AABBCCDD] => stdClass Object
(
[serial] => DEIGHNGAMDLLHHMALDBLLGBCDFMOHKLOOHEJBNBOJDELCLHGPGJIEBGJPGBHLFNCNMNOLAENOFGLEPONFPAMMGHJHNNEAHCGEHDHJCDCEPIJDKMELHBMFBLLPPBHKBMADHOBGNHMPOOJFGCHKPNEBBIBMFKJHKCBMPEGOECLKLPKBGJCBMIPNDHOOJLPLMLLLAKIKMIJNHJENLILILOLJMKICNALEIKPIAJCALJEGKHIKKDNLNPEDNOCOOGBDAFABNAAIOMB
[hardware_key_id] => AABBCCDD
[created] => 1396536543
),
[EEEEEE] => stdClass Object
(
StockTransaction.joins("LEFT JOIN line_items ON line_items.id = stock_transactions.source_id and source_type = 'LineItem'")
.joins(:product)
.where("stock_transactions.cause = 'SALE'")