Skip to content

Instantly share code, notes, and snippets.

@import <AppKit/CPView.j>
CPTextViewDidFocusNotification = @"CPTextViewDidFocusNotification";
CPTextViewDidBlurNotification = @"CPTextViewDidBlurNotification";
@implementation CPTextView : CPControl
{
DOMElement _inputElement;
id _delegate;
CPScrollView _scrollView;
@samsonjs
samsonjs / sync.js
Created January 18, 2011 04:00
poor man's bi-directional sync
#!/usr/bin/env node
// Sync two dirs giving precedence to the machine with the most recently modified files.
// After the first sync we sync again with the opposite precedence to make sure files
// deleted on either machine stay gone.
//
// The (primary) problem with this approach is that the newest changes always win. If
// you edit a file on both machines the latest changes will be the *only* remaining
// changes. Be careful if you actually use this!
#!/usr/local/bin/macruby
# This example is done with MacRuby and the UIKit framework for Mac OS X
# http://chameleonproject.org/
# https://github.com/BigZaphod/Chameleon/
framework 'Cocoa'
framework "UIKit" # garbage collected version, the current version of Chameleon ist not known to be GC-safe
###################
@alloy
alloy / NSURLConnection.rb
Created March 24, 2011 14:16
MacRuby NSURLConnection example.
framework 'AppKit'
class Download
attr_reader :response, :responseBody
def start(request)
puts "START!"
NSURLConnection.connectionWithRequest(request, delegate:self)
end
@stuarthalloway
stuarthalloway / gist:2560986
Created April 30, 2012 18:42
Datomic rule to find schema attributes whose name matches a prefix
;; The Datomic schema is made up of Datomic data, so you manipulate it
;; with ordinary queries and transactions -- and with ordinary code
;; in Java or Clojure.
;; query rule that finds attributes in schema whose names start with ?prefix
;; note the Java interop call to .startsWith
;; you could create a similar rule for namespace prefixes
(def rules '[[[attr-starts-with ?prefix ?attr]
[?e :db/valueType]
[?e :db/ident ?attr]
(ns space-age)
(defn on-earth [seconds]
(/ seconds 31557600.0))
(def orbital-periods
{:mercury 0.2408467
:venus 0.61519726
:mars 1.8808158
:jupiter 11.862615
(ns react-cljs.core
(:require-macros [reactjs.macros :refer [pure]])
(:require React [reactjs.core :as r]))
(enable-console-print!)
(declare render-ui)
(defn render-counter [id state cb]
(pure state
@ghadishayban
ghadishayban / docker_tag_paginate.clj
Last active December 21, 2016 03:48
unfold example
(ns docker-tag-paginate
(:require [clj-http.lite.client :as client]
[cheshire.core :as json]
[clojure.pprint :refer [print-table]]))
(def base-url "https://registry.hub.docker.com/v2")
;; (progression pos? dec 15)
(defn progression
@tritonrc
tritonrc / ldap_admin.rb
Created January 17, 2011 19:55
Simple Sinatra based LDAP admin tool
require 'rubygems'
require 'sinatra'
require 'net-ldap'
require 'digest/sha1'
require 'base64'
require 'haml'
LDAP_HOST = 'localhost'
ADMIN_DN = 'cn=admin,dc=company,dc=com'
@rabidpraxis
rabidpraxis / s3_mass_bucket_delete.rb
Created April 2, 2013 16:53
Delete s3 bucket with minimal api calls
require 'fog'
bucket = 'bucket-name'
credentials = {
:provider => 'AWS',
:aws_access_key_id => 'access_key_id',
:aws_secret_access_key => 'secret_key',
}
fog = Fog::Storage.new(credentials)