This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//case classes: https://github.com/karthik20522/ESQL/blob/master/src/main/scala/com/karthik/esql/sql/QueryBuilder.scala | |
import scala.util.parsing.combinator._ | |
import scala.util.parsing.combinator.syntactical._ | |
case class Query( | |
val operation: Operation, | |
val from: From, | |
val where: Option[Where], | |
val order: Option[Direction] = None, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest._ | |
class SQLParserSpec extends FunSpec with ShouldMatchers { | |
val p = new SQLParser | |
describe("given a sql string with an order clause") { | |
describe("(when direction is asc)") { | |
val sql = "select name from users order by name asc" | |
it("should be parsed into an Asc object containing the given field") { | |
val query = p.parse(sql).get |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var items = {{ order.line_items | json }}; | |
var item; | |
var productsArray = []; | |
for(var i = 0; i < items.length; i++) { | |
item = { | |
'sku': items[ i ].variant.sku, | |
'price': items[ i ].price, | |
'size': items[ i ].variant.option2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var productsArray = []; | |
{% for item in cart.items %} | |
item = { | |
'sku': '{{ item.sku }}', | |
'price': {{ item.price | money_without_currency }}, | |
'size': '{{ item.variant.option2 }}', | |
'quantity': {{ item.quantity }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImagePersistanceActor: ReceiveActor, ILogReceive { | |
public ImagePersistanceActor() { | |
Receive < string > (message => { | |
Console.WriteLine("Echo from Recieve actor: " + message); | |
}); | |
Receive < Image > (image => { | |
Console.WriteLine("OK form Receive Actor: " + image.Id); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chunkSize = 1048; //default chunksize | |
var a = new XMLHttpRequest(); | |
a.onreadystatechange = function() { | |
if (a.readyState == 4 && a.status == 200) { | |
var timeToLoad = new Date - startPingDate; | |
chunkSize = Math.round(chunkSize - (timeToLoad * Math.random())); | |
if (chunkSize < 256) | |
chunkSize = 256; //set a default value if too low |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//example: http://www.bing.com/local/default.aspx?what=Saravana&where=London | |
var html = new WebClient().DownloadString("http://www.bing.com/local/default.aspx?what=" + name + "&where=" + location); | |
var htmlDoc = new HtmlAgilityPack.HtmlDocument(); | |
htmlDoc.OptionFixNestedTags = true; | |
htmlDoc.LoadHtml(html); | |
var nodes = htmlDoc.DocumentNode.SelectNodes("//div[@class='ecEnclosure']"); | |
if (nodes != null) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Weather { | |
public string city; | |
public int curr_temp; | |
public string curr_text; | |
public int curr_icon; | |
public List < Forecast > forecast = new List < Forecast > (); | |
} | |
public class Forecast { | |
public string day_date; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Optimization; | |
namespace ClipTheTripWeb { | |
public class BundleConfig { | |
public static void RegisterBundles(BundleCollection bundles) { | |
var homeBundleJs = new Bundle("~/content/js/home", new JsMinify()); | |
homeBundleJs.Include( | |
"~/Content/Js/jquery.fullscreenr.js", | |
"~/Content/Js/jquery.autoSuggest.js", | |
"~/Content/Js/home.js" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function dock() { | |
# Point docker client and docker-machine to the given node | |
eval "$(docker-machine env --shell bash $@)" | |
} | |
# Remove all containers as well as clear out dangling images | |
function cleardock() { | |
docker rm -f $(docker ps -aq) 2> /dev/null | |
docker rmi $(docker images --filter "dangling=true" -q) 2> /dev/null |