This file contains 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
(require '[clojure.java.io :as io]) | |
(use '[clojure.string :only (join)]) | |
;; logfile contains: | |
;; login: [10.0.3.162] user1@domain.co.za plaintext User logged in | |
(def re-email #"\s+\'([a-z\.\-0-9]+?\@[a-z\.\_\-0-9]+)\'$") | |
(def re-imap-login #"login\:\s\[[0-9\.]+\]\s([a-z\.\-0-9]+?\@[a-z\.\_\-0-9]+)") | |
(defn lines-re [file] | |
(keep #(last (re-find re-imap-login %)) (line-seq (io/reader file)))) |
This file contains 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
extern crate mysql; | |
extern crate time; | |
use time::Timespec; | |
use std::num::Float; | |
use mysql::conn::{MyOpts}; | |
use mysql::conn::pool::{MyPool}; | |
use mysql::value::{from_value}; | |
use std::default::{Default}; | |
use std::f32; |
This file contains 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 | |
ROWS=10000 | |
touch result.dat | |
for ENGINE in "myisam" "innodb" | |
do | |
CSV=$ENGINE-$ROWS.csv | |
cp /dev/null $CSV | |
for threads in 2 4 6 8 | |
do |
This file contains 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
(require '[clojure.java.jdbc :as jdbc]) | |
(require '[clojure.set :as set]) | |
(use 'clojure.data) | |
(def not-nil? (complement nil?)) | |
(def sql-query ["SELECT concat(table_schema,'.',table_name) as 'schema',table_rows FROM tables | |
where table_schema <> 'mysql' | |
and table_schema <> 'information_schema' | |
and table_name NOT REGEXP '[0-9]' | |
and table_rows > 0"]) |
This file contains 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
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <map> | |
class exam { | |
int exam_questions; | |
int exam_passscore; | |
std::string exam_number; | |
std::string subject; |
This file contains 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
extern crate mysql; | |
extern crate time; | |
use mysql::conn::{MyOpts}; | |
use mysql::value::Value; | |
use mysql::conn::pool::{MyPool}; | |
use mysql::value::{from_value}; | |
use std::default::{Default}; | |
use std::vec::Vec; |
This file contains 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
;; User behaviors | |
;; ----------------------------- | |
;; Behaviors are stored as a set of diffs that are merged together | |
;; to create the final set of functionality that makes up Light Table. You can | |
;; modify these diffs to either add or subtract functionality. | |
;; | |
;; Behaviors are added to tags, objects with those tags then automatically gain | |
;; whatever logic the behavior imparts. To see a list of user-level behaviors, | |
;; start typing a word related to the functionality you want in between the square | |
;; brackets (e.g. "theme"). |
This file contains 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
select * | |
from country | |
where country.code in | |
(select code | |
from country | |
where population > 7*1000*1000) | |
and country.continent = 'Europe'; | |
QUERY PLAN | |
------------------------------------------------------------------------ |
This file contains 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
Before: | |
EXPLAIN SELECT | |
e.entry_category, | |
tp.transaction_type, | |
t.transaction_description, | |
t.transaction_date, | |
te.amount | |
FROM transaction t | |
inner join transaction_type tp on |
This file contains 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
def is_anagram(word, anagram): | |
return len(list(word)) == len([char for char in list(word) if char in list(anagram)]) | |
>>> s = "Orchestra" | |
>>> b = "Carthorse" | |
>>> [char for char in list(s) if char.lower() in b.lower()] | |
['O', 'r', 'c', 'h', 'e', 's', 't', 'r', 'a'] | |
>>> b = ['Carthorse'] | |
>>> [char for char in list(s) if char.lower() in "".join(b).lower()] |
OlderNewer