Skip to content

Instantly share code, notes, and snippets.

View leftis's full-sized avatar

Lefteris Georgatos leftis

View GitHub Profile
<?php
add_action('woocommerce_thankyou', 'order_received', 10, 1);
function order_received($order_id)
{
$order = wc_get_order($order_id);
$order_data = $order->get_data();
$quantity = $order->get_item_count();
// Needed variables
SELECT
subs."Hashed_Email" hashed_email,
T."subscriber_id",
pvc."VariationCode" variation_code,
pvc."GenopediaID" geno_id,
pvc."CampaignName",
pvc."JobID"
FROM PersadoClassicResults AS subs
left outer join PersadoVariationCodes AS pvc
ON pvc."CampaignName" = subs."Campaign_Name"
# Get rid of the startup message
startup_message off
# Stop flashing when I get an alert
vbell off
# Automatically detach if a disconnect occurs
autodetach on
# Think of it as xterm and give me scrolling

Keybase proof

I hereby claim:

  • I am leftis on github.
  • I am lefteris (https://keybase.io/lefteris) on keybase.
  • I have a public key whose fingerprint is 23C4 4F14 770B D7A2 EE6A 3A06 0574 A115 BC8F A4E9

To claim this, I am signing this object:

@leftis
leftis / test.c
Created August 16, 2015 20:41
What i don't understand ?
#include <stdio.h>
int main(int argc, char **argv) {
static int count = 0;
int (*_main)(int, char **) = &main;
if (count < 1) {
count++;
argv[0][6] = '\n';
_main(argc, argv);
@leftis
leftis / bidirection_linked_list.c
Last active August 29, 2015 14:16
Doubly linked list
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlite3.h>
#include <stdarg.h>
#define ESCAPE 27
#define CREATE_TABLE(table_name, ...) \
%define newline 0xA
section .data
hello db "Hello", newline
helloLen equ $ - hello
section .text
global start
readFile:
@leftis
leftis / money.js
Last active August 29, 2015 14:06
Number.prototype.toMoney = function(decimals, decimal_sep, thousands_sep)
{
var n = this,
c = isNaN(decimals) ? 0 : Math.abs(decimals),
d = decimal_sep || '.',
t = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
sign = (n < 0) ? '-' : '',
i = parseInt(n = Math.abs(n).toFixed(c)) + '',
j = ((j = i.length) > 3) ? j % 3 : 0;
return sign + (j ? i.substr(0, j) + t : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : '');
Number.prototype.ordinate = function(){
var num = this,
numStr = num.toString(),
last = numStr.slice(-1),
len = numStr.length,
ord = '';
switch (last) {
case '1':
ord = numStr.slice(-2) === '11' ? 'th' : 'st';
break;
def pdf_image_tag(image, options = {})
options[:src] = File.expand_path(RAILS_ROOT) + '/public' + image.split('?').first
Rails.logger.info "IMAGE_PATH: #{options[:src]}"
tag(:img, options)
end
def media_to_pdf
if project_have_media
ac = ActionController::Base.new