Skip to content

Instantly share code, notes, and snippets.

View daGrevis's full-sized avatar
⌨️
Keyboard operator

Raitis Stengrevics daGrevis

⌨️
Keyboard operator
View GitHub Profile
"use strict"
;(function($) {
$(function() {
var bookmarks = [
{url: "http://google.com/", title: "Google", category: "Search engines"},
{url: "http://duckduckgo.com/", title: "DuckDuckGo", category: "Search engines"},
{url: "http://twitter.com/", title: "Twitter", category: "Social networks"},
{url: "http://facebook.com/", title: "Facebook", category: "Social networks"},
{url: "http://dagrevis.lv/", title: "daGrevis.lv", category: "Blogs"}
]
"use strict"
;(function($) {
$(function() {
var UrlUtil = {
to_url: function(url) {
return url.replace(/\s/, "-")
},
from_url: function(url) {
return url.replace(/-/, " ")
}
@daGrevis
daGrevis / gist:4473918
Created January 7, 2013 10:23
ASCII symbols (printable chars that are not [0-9a-zA-Z])
(?=[!-~])(?=[^a-zA-Z0-9])
"use strict"
;(function($) {
$(function() {
var UrlUtil = {
to_url: function(url) {
return url.replace(/\s/, "-")
},
from_url: function(url) {
return url.replace(/-/, " ")
}
jQuery ->
class MyModel extends Backbone.Model
parse: (response) ->
response.objects
class ItemModel extends MyModel
class ItemsCollection extends Backbone.Collection
url: "/api/v1/item/"
jQuery ->
class MyModel extends Backbone.Model
parse: (response) ->
x = response.objects
console.log x
x
class ItemModel extends MyModel

What I don't like about Python

  • It's easy to get tuple where you wanted to have string and vice-versa,
In [1]: x = (
   ...:   "a",
   ...:   "b",
   ...:   "c",
   ...: )
@daGrevis
daGrevis / crypto_utils.py
Created August 21, 2013 13:14
Little abstraction for PyCrypto
import base64
from Crypto import Random
from Crypto.Cipher import AES
BLOCK_SIZE = 16
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)
unpad = lambda s: s[0:-ord(s[-1])]
import requests
import json
import envelopes
import time
DATA_URL = "http://blockchain.info/ticker"
EMAIL_ADDR = "dagrevis@gmail.com"
INTERVAL_S = 60 * 60
@daGrevis
daGrevis / euler-1.clj
Created December 27, 2013 16:08
Project Euler: Solution to Problem #1
(println
(reduce +
(filter
#(or (zero? (mod % 3)) (zero? (mod % 5)))
(range 1000)
)))