Skip to content

Instantly share code, notes, and snippets.

View lzell's full-sized avatar

Lou Zell lzell

View GitHub Profile
@mduheaume
mduheaume / .gitignore
Created January 28, 2012 17:12
Git ignore file for unity projects
Temp/
Library/
obj/
*.svd
!Library/*.asset
!Library/AssetImportState
!Library/AssetVersioning.db
!Library/BuildPlayer.prefs
!Library/ScriptMapper
@jbroadway
jbroadway / Slimdown.md
Last active July 7, 2024 08:56
Slimdown - A simple regex-based Markdown parser.
@manucorporat
manucorporat / gist:5726177
Last active December 18, 2015 04:29
Smart way to profile algorithms in C. Full project with examples coming soon!!
#include <stdio.h>
#include <stdbool.h>
#include <sys/time.h>
typedef struct _profile_buf {
const char *title;
unsigned long long total;
unsigned long long index;
struct timeval timestamp;
} profile_buf;
@jerrykrinock
jerrykrinock / How-to-Symbolize-MacOSX-Crash-Dump
Created September 25, 2013 15:26
How to symbolize a crash dump in Mac OS X, given a crash dump or exception log. Includes some steps and tips I've collected that are missing in Apple's TN2123. One time I tried this using lldb instead of gdb but it didn't work.
********************************************************
*** STEPS TO SYMBOLIZE A CRASH DUMP OR EXCEPTION LOG ***
********************************************************
1) Move/copy both the crashing .app and the relevant.dSYM files into the same directory.
2) If the crash was in a framework, dynamic library, or bundle, you have position-independent code and must work out the *slide*. Otherwise, skip up to step 9 and use slide=0.
3a) If you have a crash dump, look in the *Binary Images* part of the crash log and find the framework, dynamic libray or bundle in which the crash occurred. Read the first column of the output. This is the address at which the __TEXT segment was loaded. We call it the *Actual Load Address* and denote it as *A*.
@lzell
lzell / xctesting_in_repl_or_script.swift
Created August 11, 2016 20:01
Using XCTest in the swift repl or standalone script
// Start repl with:
// $ xcrun swift -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
// Or run as script:
// $ xcrun swift -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks %
import Foundation
if dlopen("/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Versions/A/XCTest", RTLD_NOW) == nil {
@briankc
briankc / NSScreen+CGDirectDisplayID.swift
Last active August 7, 2023 16:38
Get display ID from NSScreen for use with CGDirectDisplay API
import Cocoa
import CoreGraphics
extension NSScreen {
var displayID: CGDirectDisplayID {
return deviceDescription["NSScreenNumber"] as? CGDirectDisplayID ?? 0
}
}
@zappycode
zappycode / NSImageToJpeg.swift
Last active June 12, 2024 02:15
Coverting an NSImage into JPEG Data
func jpegDataFrom(image:NSImage) -> Data {
let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil)!
let bitmapRep = NSBitmapImageRep(cgImage: cgImage)
let jpegData = bitmapRep.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:])!
return jpegData
}
@shivasiddharth
shivasiddharth / videoupscaler.py
Last active September 1, 2023 22:06
Script to upscale videos using OpenCV and ffmpeg
#!/usr/bin/env python
# Written by Shivasiddharth a.k.a Sid
# Youtube channel https://www.youtube.com/c/SidsEClassroom
# Share this script without removing the author's name
# This piece of script Upscales or Downscales videos using Opencv
# If the original video has an audio stream,
# it will merge the audio from the source file with the scaled video
@kohheepeace
kohheepeace / memo.md
Last active May 13, 2024 06:19
Rails ajax comparison (fetch, Rails.ajax, axios, @rails/request.js, Turbo)

Rails ajax comparison (fetch, Rails.ajax, axios, @rails/request.js, Turbo)

I wrote this gist because I felt that the Rails documentation was lacking a description of ajax requests.

📌 Options for ajax request

There are various ways to send ajax requests in Rails.

  1. Browser default Fetch API
  2. Rails.ajax (No Official docs and request for docs)
  3. http client like axios
  4. @rails/request.js 👈 I'm using this one now !