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
(ns scratch.core) | |
(defn dividable? [number] | |
#(zero? (mod number %)) | |
) | |
(defn dividableByAny? [number divList] | |
(> (count (filter (dividable? number) divList)) 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
(defn convert [](with-open [rdr (reader "/Users/zhaowang/workspace/clojure/labrepl/data/words")] | |
(doseq [line (take 2000 (line-seq rdr))] | |
(writeToFile (str "\"" line "\"" ","))))) | |
(defn writeToFile [line] | |
(with-open [wrtr (writer "test.json" :append true)] | |
(.write wrtr line))) |
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
; From Clojure: the JFDI language by Michael O. Church | |
; https://docs.google.com/presentation/d/16ccLdZ6Epp6Nu-lMansEErwAjbN4sau4LztaARmdl_k/edit#slide=id.g1793dde48_1508 | |
; Motivation: runtime tracing of functions is a powerful debug technique. | |
; It’d require a framework to do this in Java, but in Clojure, a macro suffices! | |
(defmacro tracing [code] | |
`(do | |
(println "The code was: " '~code) |
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
(dotimes [n (read-string (read-line))] | |
(let [x (read-string (read-line)), | |
ex (fn [x] | |
(inc | |
(reduce + | |
(map #(/ (reduce * (repeat % x)) | |
(reduce * (range 1 (inc %))) | |
) | |
(range 1 10) | |
) |
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
// Note: This must be used in an Xcode project that contains a bridging header | |
// that includes <asl.h> | |
import Foundation | |
/// Provides high-level methods to access the raw data in | |
/// an ASL message. | |
struct SystemLogEntry { | |
/// Key-value pairs read from ASL message | |
let data: [String : String] |
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
#!/usr/bin/env ruby | |
device_types_output = `xcrun simctl list devicetypes` | |
device_types = device_types_output.scan /(.*) \((.*)\)/ | |
runtimes_output = `xcrun simctl list runtimes` | |
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/ | |
devices_output = `xcrun simctl list devices` | |
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/ |
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
find ./ -name ".svn" | xargs rm -Rf |
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
System.NullReferenceException: Object reference not set to an instance of an object | |
at Mono.TextEditor.Utils.RtfWriter.GenerateRtf (Mono.TextEditor.TextDocument doc, ISyntaxMode mode, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options) [0x00061] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/57eb8135/source/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Utils/RtfWriter.cs:71 | |
at Mono.TextEditor.ClipboardActions+CopyOperation.SetData (Gtk.SelectionData selection_data, UInt32 info) [0x00067] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/57eb8135/source/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/ClipboardActions.cs:97 | |
at Mono.TextEditor.ClipboardActions+CopyOperation.ClipboardGetFunc (Gtk.Clipboard clipboard, Gtk.SelectionData selection_data, UInt32 info) [0x00000] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/57eb8135/source/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEd |
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
/// <summary> | |
/// Sending email using Amazon SES | |
/// </summary> | |
public class AmazonSES | |
{ | |
private static string accessKey = your access key in string; | |
private static string secretKey = your access secret key; | |
private static string _fromEmail = "yourname@example.com"; | |
private static int _maximumDeliveryAttempts = 3; |
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
/// <summary> | |
/// Functions for sending emails using SendGrid | |
/// </summary> | |
public class SendGrid | |
{ | |
#region Dependency and Initialization | |
private static SendingEmailSetting setting; | |
/// <summary> | |
/// This need to be set up when application starts |
OlderNewer