Skip to content

Instantly share code, notes, and snippets.

@ashga
ashga / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
SageDataObject190.SDOEngine oSDO = new SageDataObject190.SDOEngine();
SageDataObject190.WorkSpace oWS;
SageDataObject190.SalesRecord oSalesRecord;
//SageDataObject190.SopRecord oSopRecord;
SageDataObject190.SopItem oSopItem;
//SageDataObject190.SopItem oSopItem_Write;
SageDataObject190.SopPost oSopPost;
SageDataObject190.StockRecord oStockRecord;
//oWS = (SageDataObject190.WorkSpace)oSDO.Workspaces.Add("Example");
@ashga
ashga / q6.js
Created October 16, 2012 19:38
Question 6 javascript
for (var i = 0; i < divs.length; i++) {
divs[i].style.color = "black"
.style.border = thickness + 'px solid blue'
.style.backgroundColor = "white";
}
for(var i = 0; i < 1000; i++){
@ashga
ashga / check_prop.cs
Created October 16, 2012 19:12
Question 3 Class
using System;
using System.Collections.Generic;
public delegate void FoundString(string found);
public class WhatDoIDo
{
private ILogger _logger = new Logger();
private readonly List<object> _objects = new List<object>();
public event FoundString Found;
@ashga
ashga / scripts.sql
Created October 16, 2012 18:47
Question 4 & 5 Database
4a. select * from employee where age > 40;
4b. select top 1 * from employee order by age desc;
4c .select top 1 lastname,count(*) as count from employee group by lastname order by count desc;
4d. select lastname,count(*) as count from employee where count > 10 group by lastname HAVING COUNT(lastname) > 10 order by count desc;
5. SELECT employee.lastname +', '+employee.forename as 'employee_name' ,department.deptdesc AS 'department'
FROM department INNER JOIN
@ashga
ashga / Anagrams.cs
Created October 16, 2012 17:46
Question 2 Anagrams
public static bool IsAnagram(string WordA, string WordB)
{
return WordA.OrderBy(x => x).SequenceEqual(WordB.OrderBy(x => x));
}
@ashga
ashga / program.cs
Created October 16, 2012 17:32
Question 1 BrightSolid
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BrightSolid
{
class Program
{
@ashga
ashga / query_products.sql
Created September 15, 2012 08:39
generated sql query for spree
SELECT DISTINCT `spree_products`.* FROM `spree_products` INNER JOIN `spree_variants` ON
`spree_variants`.`product_id` = `spree_products`.`id` AND `spree_variants`.deleted_at IS NULL AND
`spree_variants`.is_master = 1 INNER JOIN `spree_products_taxons` ON
`spree_products_taxons`.`product_id` = `spree_products`.`id` INNER JOIN `spree_taxons` ON
`spree_taxons`.`id` = `spree_products_taxons`.`taxon_id` INNER JOIN `spree_product_properties` ON
`spree_product_properties`.`product_id` = `spree_products`.`id` WHERE `spree_products`.`deleted_at` IS
NULL AND `spree_taxons`.`id` IN (307170557) AND (available_on <= '2012-09-15 08:27:25') AND (
spree_variants.price >= 500.00 AND spree_products.id IN (SELECT spree_product_properties.product_id
FROM spree_product_properties where spree_product_properties.property_id = 33113319 AND
spree_product_properties.value = 'Acer' OR spree_product_properties.value = 'HP' ) AND
@ashga
ashga / taxon_decorator.rb
Created September 12, 2012 16:03
Taxons Filter
module Spree
Spree::Taxon.class_eval do
include ::Spree::ProductFilters # for detailed defs of filters
def get_attributes(taxon)
@ashga
ashga / product_gen.rb
Created July 4, 2012 13:51
this is some code that generates a csv for amazon and uses a Resque task so it runs in the background
class Spree::Admin::AmazonProduct < ActiveRecord::Base
attr_accessible :Description, :FileName, :Title, :template
@queue = :amazon_products
def self.perform(id,filename,site)
puts "#{Time.now}"
start_time = Time.now
puts "loading products..."