Skip to content

Instantly share code, notes, and snippets.

View antarr's full-sized avatar
💭
🤷🏾‍♂️

antarr antarr

💭
🤷🏾‍♂️
View GitHub Profile
@parshap
parshap / cpus.rb
Last active August 25, 2021 21:34
Determine number of cpu cores to use in Vagrant
# Determines how many cpus the virtual machine should be given. Uses half of
# what's available on the host with a default of 4.
def numvcpus
begin
os_cpu_cores / 2
rescue
4
end
end
@katemonkeys
katemonkeys / gist:e17580777b57915f5068
Last active February 20, 2024 15:36
Everything Wrong With The Withings API

Top Six Things You Need To Know About The Withings API*

*where “you” is probably a developer, or at least a strange user

I should preface this by saying that I got a Withings Smart Body Analyzer for Christmas last year and I’ve been generally happy with it. It purports to be able to take my heart rate through my bare feet and that seems not to work for my physiology, but overall I’m a fan. If if their Wikipedia page is to be believed they are having a pretty rad impact on making the Quantified Self movement more for normal people and they only have 20 full time employees. Also they try hard to use SI units, which I can get behind. Anyway, on to the rant.

I originally called this post “Everything wrong with the Withings API” and I meant it. For every useful field I can extract from their “award winning” app, I have spent an hour screaming at the inconsistencies in their implementation or inexplicable holes in their data

@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@PetersonDave
PetersonDave / gist:6800139
Created October 2, 2013 20:36
Prevent users from submitting forms twice in Sitecore's Web Forms for Marketers.
using System;
using Sitecore.Form.Core.Renderings;
using Sitecore.Form.Web.UI.Controls;
namespace Custom.Form.Web.UI.Controls
{
public class PreventDoubleClickFormRender : FormRender
{
// disables submit button if group validator for submit is valid
private const string PreventDoubleSubmitJs = @"function disableSubmitButton(groupValidator, submitButton) {{ $(submitButton).disabled = Page_ClientValidate(groupValidator);}}";
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@dkubb
dkubb / ev.rb
Created March 16, 2011 22:13
Poor-man's Embedded Value
class User
include DataMapper::Resource
property :id, Serial
property :username, String, :required => true, :unique => true
property :address_street_address, String
property :address_location, String
property :address_subdivision, String
property :address_country, String
@collectiveidea
collectiveidea / application.html.erb
Created August 21, 2009 19:59
How to get jQuery to work with Rail's Authenticity Token (protect_from_forgery)
<!DOCTYPE html>
<html>
<head>
<title>My Rails App</title>
<%- if protect_against_forgery? -%>
<meta name="authenticity-token" id="authenticity-token" content="<%= form_authenticity_token %>" />
<%- end -%>
<%= javascript_include_tag 'jquery', 'rails' %>
</head>
<body>