Skip to content

Instantly share code, notes, and snippets.

@perfectfoolish
perfectfoolish / InstallOracleJava8JDK.sh
Last active September 8, 2017 19:51
Oracle Java 8 JDK Downloads Page: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Notice: Use the md5sum command line utility on Linux to verify the integrity of the downloaded file. Java SE Binaries Checksum: https://www.oracle.com/webfolder/s/digest/8u40checksum.html
# How To Install Java on CentOS and Fedora
# https://www.digitalocean.com/community/tutorials/how-to-install-java-on-centos-and-fedora
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.tar.gz"
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.rpm"
@toioski
toioski / UIButton+ClipBackgroundImageToBounds.swift
Last active August 29, 2015 14:17
Conversion to Swift of Barry Allard UIView+ClipBackgroundImageToBounds
//
// UIView+ClipBackgroundImageToBounds.m
//
// Created by Barry Allard on 2013-06-18.
// Copyright (c) 2013 Stealth Mode Industries LLC. All rights reserved.
//
// Based on http://stackoverflow.com/questions/262156/uiimage-rounded-corners
//
// MIT License

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@cfr
cfr / main.c
Last active August 29, 2015 14:15
iOS kernel panic
// Content source: https://medium.com/@oleavr/diy-kernel-panic-os-x-and-ios-in-10-loc-c250d9649159
// HN thread: https://news.ycombinator.com/item?id=9085536
#include <unistd.h>
#include <mach/mach.h>
#include <mach-o/dyld.h>
extern kern_return_t mach_vm_protect(vm_map_t, mach_vm_address_t, mach_vm_size_t,
boolean_t, vm_prot_t);
@aktau
aktau / homebrew-llvm351-error.log
Created January 24, 2015 11:28
Failing homebrew/versions/llvm35 (3.5.1) build
llvm[6]: ======= Finished Linking Release+Asserts Unit test ClangApplyReplacementsTests (without symbols)
llvm[6]: Compiling UniqueHeaderNameTest.cpp for Release+Asserts build
if clang++ -I/private/tmp/llvm35-g2huGt/llvm-3.5.1.src/include -I/private/tmp/llvm35-g2huGt/llvm-3.5.1.src/tools/clang/tools/extra/unittests/clang-modernize -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/private/tmp/llvm35-g2huGt/llvm-3.5.1.src/tools/clang/tools/extra/unittests/clang-modernize/../../../../include -I/private/tmp/llvm35-g2huGt/llvm-3.5.1.src/tools/clang/tools/extra/unittests/clang-modernize/../../../../include -I/private/tmp/llvm35-g2huGt/llvm-3.5.1.src/tools/clang/tools/extra/unittests/clang-modernize/../../clang-modernize -I/private/tmp/llvm35-g2huGt/llvm-3.5.1.src/tools/clang/tools/extra/unittests/clang-modernize/../../clang-apply-replacements/include -I/private/tmp/llvm35-g2huGt/llvm-3.5.1.src/tools/clang/tools/extra/unittests/clang-modernize/../include -I/private/tmp
hfm@giant [~/program/test-serf] [perl v5.21.2] [ruby 2.2.0preview1] [python 2.7.8]
$ puppet --version
/Users/hfm/.rbenv/versions/2.2.0-preview1/lib/ruby/gems/2.2.0/gems/puppet-3.7.1/lib/puppet/vendor/safe_yaml/lib/safe_yaml/syck_node_monkeypatch.rb:42:in `<top (required)>': uninitialized constant Syck (NameError)
from /Users/hfm/.rbenv/versions/2.2.0-preview1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/hfm/.rbenv/versions/2.2.0-preview1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/hfm/.rbenv/versions/2.2.0-preview1/lib/ruby/gems/2.2.0/gems/puppet-3.7.1/lib/puppet/vendor/safe_yaml/lib/safe_yaml.rb:197:in `<module:YAML>'
from /Users/hfm/.rbenv/versions/2.2.0-preview1/lib/ruby/gems/2.2.0/gems/puppet-3.7.1/lib/puppet/vendor/safe_yaml/lib/safe_yaml.rb:132:in `<top (required)>'
from /Users/hfm/.rbenv/versions/2.2.0-preview1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/hfm/.rbenv/versions/2.2.0-preview1/lib/r
@revskill10
revskill10 / lopmonhoc.js.jsx
Created January 22, 2014 09:25
Integrate Datatable with React.js
/** @jsx React.DOM */
var LopMonHoc = React.createClass({
getInitialState: function(){
return {data: []}
},
loadData: function(){
$.ajax({
url: '/daotao/lops',
success: function(data){
require "net/https"
require "uri"
require 'json'
uri = URI.parse("https://www.howsmyssl.com/a/check")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
resp = JSON.parse(http.request(Net::HTTP::Get.new(uri.request_uri)).body)
puts JSON.pretty_generate(resp)
@walesmd
walesmd / IconServiceAgent.md
Last active December 13, 2023 05:06
A lot of people are having issues with com.apple.IconServicesAgent. Since this is a very new issue, Google was no help and `man iconservicesd` is even more hilarious. I eventually fixed it, when I was working on a completely different issue (that is still not fixed). The instructions are below and on the Apple Support Forum, https://discussions.…

I was chasing down another issue (slow "Save As") and thought these two issues may have been related (with QuickLook being the common broken link). Unfortunately, my "Save As" dialog is still miserably slow on the initial load; but IconServicesAgent hasn't gone above 30MB and he rarely makes an appearance in the Console!

Some of these steps may not be necessary, but here are all of the steps I took that inadverdently put IconServicesAgent back in its place. Note: all commands are a single-line, if they appear to be multiple that's just the forum formatting.

  1. Check for any QuickLooks related .plist files. In a terminal: mdfind com.apple.quicklook. -name .plist

  2. I only had files at the system level (specifically within /System/Library/LaunchAgents/). If you have others, modify the directions below to take that into account (re-introducing plist files from the system level back up to the user).

  3. Make some temporary directories to store these plist files, just in case: mkdir ~/tmp-quicklook

@willurd
willurd / web-servers.md
Last active May 23, 2024 08:59
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000