Skip to content

Instantly share code, notes, and snippets.

Seivan seivan

Block or report user

Report or block seivan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
prendio2 / SUPTableViewController.m
Created Mar 26, 2014
Custom viewWillApear to restore selected row when transition is cancelled
View SUPTableViewController.m
- (void)viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];
NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow];
if (selectedRowIndexPath) {
[self.tableView deselectRowAtIndexPath:selectedRowIndexPath animated:YES];
[[self transitionCoordinator] notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) {
if ([context isCancelled]) {
[self.tableView selectRowAtIndexPath:selectedRowIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
bitwalker / config.ex
Created Jul 19, 2016
Useful config wrapper for Elixir
View config.ex
defmodule Config do
@moduledoc """
This module handles fetching values from the config with some additional niceties
@doc """
Fetches a value from the config, or from the environment if {:system, "VAR"}
is provided.
An optional default value can be provided if desired.
xem /
Last active Jan 22, 2020
Maths & trigonometry cheat sheet for 2D & 3D games


  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

Jaybles / UIDeviceHardware.h
Created Oct 28, 2011
UIDeviceHardware - Determine iOS device being used
View UIDeviceHardware.h
// UIDeviceHardware.h
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
lucamarrocco / app.swift
Last active Nov 25, 2019
swift osx application without nib
View app.swift
import Cocoa
class WindowController: NSWindowController {
class AppDelegate: NSObject {
var mainWindow: NSWindow?
var mainController: NSWindowController?
Twinklebear / main.cpp
Last active Oct 23, 2019
Example of render to texture with SDL2
View main.cpp
#include <iostream>
#ifdef __linux__
#include <SDL2/SDL.h>
#elif defined(_WIN32)
#include <SDL.h>
const int WIN_WIDTH = 640;
const int WIN_HEIGHT = 480;
bsedat / Dockerfile
Last active Oct 17, 2019
Elixir Phoenix Umbrella App + Distillery Multistage Docker Build
View Dockerfile
FROM elixir:1.4.5 as asset-builder-mix-getter
ENV HOME=/opt/app
RUN mix do local.hex --force, local.rebar --force
# Cache elixir deps
COPY config/ $HOME/config/
COPY mix.exs mix.lock $HOME/
COPY apps/myproject_web/mix.exs $HOME/apps/myproject_web/
COPY apps/myproject_web/config/ $HOME/apps/myproject_web/config/
kharrison / Country.swift
Last active Sep 24, 2019
Swift Hash Functions
View Country.swift
import Foundation
struct Country {
let name: String
let capital: String
var visited: Bool
extension Country: Equatable {
static func == (lhs: Country, rhs: Country) -> Bool {
mattpodwysocki / eventsource.js
Last active Sep 23, 2019
Adding support for server-sent events for RxJS
View eventsource.js
if (!!root.EventSource) {
* This method wraps an EventSource as an observable sequence.
* @param {String} url The url of the server-side script.
* @param {Observer} [openObserver] An optional observer for the 'open' event for the server side event.
* @returns {Observable} An observable sequence which represents the data from a server-side event.
dom.fromEventSource = function (url, openObserver) {
return new AnonymousObservable(function (observer) {
use std::path::PathBuf;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::thread;
use std::os::raw::c_void;
use std::rc::Rc;
use std::cell::{Cell, RefCell};
use std::i16;
use std::time::Instant;
use failure::{err_msg, Error};
You can’t perform that action at this time.