Skip to content

Instantly share code, notes, and snippets.

View ahbou's full-sized avatar
shipping

Ahmed Bouchfaa ahbou

shipping
View GitHub Profile
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
// generic select function
const $ = selector => […document.querySelectorAll(selector)];
// usage
$(“div”).forEach(el => el.classList.add(“foo”));
// NSString_stripHtml.h
// Copyright 2011 Leigh McCulloch. Released under the MIT license.
#import <Foundation/Foundation.h>
@interface NSString (stripHtml)
- (NSString*)stripHtml;
@end
@ahbou
ahbou / capybara cheat sheet
Created January 8, 2016 18:41 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@ahbou
ahbou / FCPrivateBatteryStatus.m
Created January 30, 2016 00:04
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);

Keybase proof

I hereby claim:

  • I am ahbou on github.
  • I am ahbou (https://keybase.io/ahbou) on keybase.
  • I have a public key whose fingerprint is C4FB 1E06 E840 050B 7969 713E 132A E782 14BC 87D7

To claim this, I am signing this object:

@ahbou
ahbou / DumpiOSFonts.m
Last active June 21, 2016 15:45 — forked from shannoga/gist:1008678
Get fonts family and font names list on iOS
// List all fonts on iPhone
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily < familyNames.count; ++indFamily)
{
NSLog(@"Family name: %@", familyNames[indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:familyNames[indFamily]]];
<?
/*
This is part of the Reprise framework, not yet released publicly.
Copyright 2013 Marco Arment. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@ahbou
ahbou / rails_setup.sh
Last active December 15, 2016 11:04
Managing multiple Rails version with Bundler and rbenv
# make sure homebrew is up to date
brew update
# update ruby version
brew upgrade ruby-build
# install latest stable version
rbenv install 2.3.3
#set version as global
rbenv global 2.3.3
#install bundler for that ruby version
gem install bundler
@ahbou
ahbou / fresh-mac-setup.md
Created January 9, 2017 15:20 — forked from bernsno/cmal-fresh-mac-setup.md
Fresh Mac Setup

New Computer Setup

Last tested using Mac OS X 10.8 Mountain Lion

Before Wiping Original Install

  • Backup .ssh folder to avoid having to regenerate codes for services such as Heroku and Github.