I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
This file contains hidden or 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
// This is C++11-only because it assumes that std::strings can | |
// be accessed and mutated as a contiguous sequence of chars. | |
std::string sys::readlink (const char* pathname) | |
{ | |
std::string buffer(64, '\0'); | |
ssize_t len; | |
while ((len = ::readlink(pathname, &buffer[0], buffer.size())) == static_cast<ssize_t>(buffer.size())) { | |
// buffer may have been truncated - grow and try again | |
buffer.resize(buffer.size() * 2); |
This file contains hidden or 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
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited | |
# | |
# Current known FCC address ranges: | |
# https://news.ycombinator.com/item?id=7716915 | |
# | |
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft | |
# | |
# In your nginx.conf: | |
location / { |
This file contains hidden or 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 | |
# | |
# DESCRIPTION: | |
# | |
# Set the bash prompt according to: | |
# * the active virtualenv | |
# * the branch of the current git/mercurial repository | |
# * the return value of the previous command | |
# * the fact you just came from Windows and are used to having newlines in | |
# your prompts. |
This file contains hidden or 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
// jpeg_split.c: Write each scan from a multi-scan/progressive JPEG. | |
// This is based loosely on example.c from libjpeg, and should require only | |
// libjpeg as a dependency (e.g. gcc -ljpeg -o jpeg_split.o jpeg_split.c). | |
#include <stdio.h> | |
#include <jerror.h> | |
#include "jpeglib.h" | |
#include <setjmp.h> | |
#include <string.h> | |
void read_scan(struct jpeg_decompress_struct * cinfo, |
This file contains hidden or 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
SHELL = /bin/bash | |
EXENAME = foo | |
SRCDIR = src | |
OBJDIR = obj | |
NO_COLOR=\033[0m | |
OK_COLOR=\033[32;01m | |
ERROR_COLOR=\033[31;01m |
This file contains hidden or 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
// main.m | |
// creategif | |
// | |
// Created by Kevin Meaney on 21/10/2013. | |
// I've briefly blogged about it here: | |
// http://blog.yvs.eu.com/2013/10/creating-gif-animations-using-coreimagequartz | |
// The following code is all that is all the code needed for a creating a command line tool to generate | |
// a gif animation from image files. | |
// The main limitation with this code is that apart from the frame delay time of 0.1 second, every |
This file contains hidden or 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
static UIImage * UIImageForSwatchOfColorWithSize(UIColor *color, CGSize size) { | |
UIImage *image = nil; | |
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height); | |
UIGraphicsBeginImageContext(rect.size); | |
{ | |
CGContextRef c = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(c, [color CGColor]); |
This file contains hidden or 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
// | |
// SPTexture+PNGErrorHandler.h | |
// | |
// Created by Shilo White on 9/3/13. | |
// | |
// | |
#import "SPTexture.h" | |
@interface SPTexture (PNGErrorHandler) |
This file contains hidden or 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
# Ensure we're in a virtualenv. | |
if [ "$VIRTUAL_ENV" == "" ] | |
then | |
echo "ERROR: not in a virtual environment." | |
exit -1 | |
fi | |
# Setup variables. | |
CACHE="/tmp/install-pygtk-$$" |