Skip to content

Instantly share code, notes, and snippets.

View inket's full-sized avatar
😷
Busy with work/life

Mahdi Bchatnia inket

😷
Busy with work/life
View GitHub Profile
@inket
inket / PreviewScreenshot.swift
Last active February 1, 2024 06:14
How to take screenshots of SwiftUI previews
#if DEBUG
import SwiftUI
private let screenshotDirectory = "/Users/inket/Desktop/"
struct PreviewScreenshot: ViewModifier {
struct LocatorView: UIViewRepresentable {
let tag: Int
func makeUIView(context: Context) -> UIView {
@inket
inket / covid-tweetbot-filters.md
Created April 2, 2020 08:31
Tweetbot mute regex for covid-related words. Stay home and stop following the stressful covid news cycle.
(?:(?i)covid|corona|quarantine|virus|wash|spread|WFH|outbreak|infection|vaccine|treatment|health|economy|lockdown|ventilator|mask|zoom|pandemic|crisis|distancing|hospital|health|cases|died|death|testing|positive|sanitize|ECMO|china|italy|spain|trump|governor)|WHO|CDC

Muted words

covid corona quarantine virus

Keybase proof

I hereby claim:

  • I am inket on github.
  • I am inket (https://keybase.io/inket) on keybase.
  • I have a public key whose fingerprint is 1C2C 9389 FAFA F6CD 3D23 C0C6 5327 75AD BC03 F6C5

To claim this, I am signing this object:

@inket
inket / fivethirtyeight-election.rb
Created November 8, 2016 07:07
fivethirtyeight 2016 election forecast
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open('http://projects.fivethirtyeight.com/2016-election-forecast/'))
puts 'CLINTON '+doc.css('.winprob-bar .candidate.one.dem .candidate-val.winprob').text+' - '+doc.css('.winprob-bar .candidate.three.rep .candidate-val.winprob').text+' TRUMP'
# bash for geektool:
# ruby -e "require 'open-uri'; require 'nokogiri'; doc = Nokogiri::HTML(open('http://projects.fivethirtyeight.com/2016-election-forecast/')); puts 'CLINTON '+doc.css('.winprob-bar .candidate.one.dem .candidate-val.winprob').text+' - '+doc.css('.winprob-bar .candidate.three.rep .candidate-val.winprob').text+' TRUMP'"
@inket
inket / heroku-youtube-dl.rb
Last active February 2, 2016 15:02
heroku-youtube-dl
# Usage:
# ruby -e "$(curl <url_to_this_raw_gist>)" https://www.youtube.com/watch?v=Jo1tjBmwuXI
youtube_url = ARGV[0]
puts "YouTube URL: #{youtube_url}"
`mkdir youtube`
Dir.chdir "youtube"
`curl https://yt-dl.org/downloads/2014.10.13/youtube-dl > youtube-dl`
@inket
inket / update_xcode_plugins.rb
Created June 3, 2014 19:01
Updates your Xcode plug-ins to make them load on Xcode 6.0 Beta (6A215l)
# Run this to make your plugins load on Xcode 6 Beta [Version 6.0 (6A215l)]
# - Does NOT insure that your installed plugins will run fine on the new version.
# - Alcatraz (the package manager) might update the plugins or reset them;
# In that case, you'll need to run this script again
new_uuid = "AD68E85B-441B-4301-B564-A45E4919A6AD"
plugins_path = Dir.home+"/Library/Application Support/Developer/Shared/Xcode/Plug-ins/"
unless Dir.exist?(plugins_path)
puts "Couldn't find Plug-ins directory."
@inket
inket / plugin.m
Created May 31, 2014 16:33
Swizzling dynamically-loaded Lookup.framework
- (void)loadPlugin {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(bundleDidLoad:) name:@"NSBundleDidLoadNotification" object:nil];
}
- (void)bundleDidLoad:(NSNotification*)note {
if ([[note object] isKindOfClass:[NSBundle class]])
{
NSBundle* loadedBundle = [note object];
if ([@"com.apple.LookupFramework" isEqualToString:[loadedBundle bundleIdentifier]])
{
@inket
inket / build-script.sh
Last active January 2, 2016 06:29
My own take of versioning with Xcode and git.
# This build script is based on http://kylefuller.co.uk/posts/versioning-with-xcode-and-git/
# Difference is that instead of having to use git to increment your app's version (git tag <version>),
# you could simply use Xcode as usual. This script would automatically create a tag for that version if it's a new one.
CURRENT_TAG=$(git describe --tags --abbrev=0)
CURRENT_VERSION=$(defaults read "${SOURCE_ROOT}/${INFOPLIST_FILE%.*}" "CFBundleShortVersionString")
# Create a tag for this version, if it doesn't exist
if [[ $CURRENT_VERSION != $CURRENT_TAG ]];
then git tag $CURRENT_VERSION;