Skip to content

Instantly share code, notes, and snippets.

@mathieulegrand
mathieulegrand / keybase.md
Created February 9, 2017 03:40
Keybase proof

Keybase proof

I hereby claim:

  • I am mathieulegrand on github.
  • I am legrand (https://keybase.io/legrand) on keybase.
  • I have a public key ASAeBLSEgh2mB8FtmCjY17Pu3cvzLJzFU_hRtNgfvq-SSwo

To claim this, I am signing this object:

@mathieulegrand
mathieulegrand / FCPrivateBatteryStatus.m
Created January 30, 2016 03:01
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);
@mathieulegrand
mathieulegrand / keyboard.cljs
Last active August 29, 2015 14:21
Editable DIV as a IRC style input bar (textarea replacement) in ClojureScript
(ns potato.keyboard
(:require [clojure.string]
[goog.dom]
[goog.style]
[goog.events]
[goog.dom.xml]
[goog.dom.classlist]
[goog.dom.selection]
[goog.testing.events]
[goog.events.EventTarget]
om/IWillMount
(will-mount [_]
(go-loop []
(async/<! wait-for-channel-event)
(log (str "Atom first is " (:date (apply min-key :date (:content (deref data))))))
(let [new-from-server (async/<! (fetch-from-server url (:id (apply min-key :date (:content (deref data))))))]
(log (str "Server first is " (:date (apply min-key :date new-from-server))))
(om/transact! data :content #(apply conj % new-from-server))
(recur)))
@mathieulegrand
mathieulegrand / fsa.py
Last active August 29, 2015 14:11 — forked from danielpunkass/fsa.py
"""
Automate loading of F-Script Anywhere into any app.
By Daniel Jalkut - @danielpunkass - http://indiestack.com/
To set up:
0. Make sure you have FScript.framework installed in /Library/Frameworks (http://www.fscript.org)
1. Copy this script to ~/.lldb/fsa.py
2. Add the following to your ~/.lldbinit file:
@mathieulegrand
mathieulegrand / Vagrantfile
Created April 4, 2014 02:03
Vagrant workaround to set hostname with vSphere provider
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# [...]
config.vm.hostname = 'my-hostname.fully.qualified'
config.vm.provider :vsphere do |vsphere|
# [...]
end
@mathieulegrand
mathieulegrand / connect.rs
Last active March 10, 2018 19:57
simple connect to server:443 in Rust
// Rust 0.10-pre (Tue Mar 18, 2014)
// $ rustc -L rust-openssl/build/ -L rust-toml/lib doing.rs
// assuming https://github.com/sfackler/rust-openssl is cloned and compiled,
// and https://github.com/mneumann/rust-tom is cloned and compiled
#[feature(macro_rules)];
#[allow(deprecated_owned_vector)];
extern crate openssl;
extern crate serialize;
tm-test-wc(master*)$ svn status --no-ignore -v --xml
<?xml version="1.0"?>
<status>
<target
path=".">
<entry
path=".">
<wc-status
props="normal"
item="normal"
@mathieulegrand
mathieulegrand / area_code.rb
Created July 3, 2011 13:55 — forked from mager/area_code.rb
Get area code from IP address using SimpleGeo Places & Ruby
SimpleGeo::Client.set_credentials(ENV['SIMPLEGEO_KEY'],ENV['SIMPLEGEO_SECRET'])
resp = SimpleGeo::Client.geocode_from_ip()
options = {:num=>1}
place = SimpleGeo::Client.get_places(resp[:query][:latitude], resp[:query][:longitude], options)
phone = place[:features][0][:properties][:phone]
@area_code = phone[3..-10] # Phone number format: "+1 XXX XXX-XXXX"
XXXXXXXXX::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true