Skip to content

Instantly share code, notes, and snippets.

View dhavaln's full-sized avatar
💭
I may be slow to respond.

Dhaval Nagar dhavaln

💭
I may be slow to respond.
View GitHub Profile
@nilcolor
nilcolor / Node.js CORS
Created February 8, 2011 15:28
Node.js cross-origin POST. You should response for OPTIONS request first. Something like this.
if (req.method === 'OPTIONS') {
console.log('!OPTIONS');
var headers = {};
// IE8 does not allow domains to be specified, just the *
// headers["Access-Control-Allow-Origin"] = req.headers.origin;
headers["Access-Control-Allow-Origin"] = "*";
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
headers["Access-Control-Allow-Credentials"] = false;
headers["Access-Control-Max-Age"] = '86400'; // 24 hours
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept";
@artero
artero / launch_sublime_from_terminal.markdown
Last active January 25, 2024 16:57 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@davidnunez
davidnunez / gist:1404789
Created November 29, 2011 13:20
list all installed packages in android adb shell
pm list packages -f
@martinmidtsund
martinmidtsund / heroku-deploy
Last active April 3, 2017 09:52
Script for deploying a Meteor.js application to Heroku. The script will create a new application on Heroku with the given APPNAME, and add a MongoHQ addon, with the Sandbox plan(free plan with 512 MB MongoDB). It will then deploy your Meteor.js app to heroku.
#!/bin/bash
# Deploy script for Meteor.js to Heroku
#
# Author: Martin A. Midtsund / martin@iterate.no
#
# Before running this script, you need to have these tools in your path:
# meteor - To install: $ curl https://install.meteor.com | sh
# heroku - Install Heroku toolbelt and log in to your user: https://toolbelt.heroku.com/
# git - You'll get this in the Heroku toolbelt, if you don't already have it.
#
@codeshrew
codeshrew / open-chrome-disable-web-security.scpt
Last active March 31, 2019 22:27
Launches Google Chrome with web security disabled. This disables the same origin policy for API calls and can ease development from a dev environment not in a server's CORS settings
(* Launches Google Chrome with web security disabled.
This disables the same origin policy for API calls and can
ease development from a dev environment not in a server's CORS settings *)
(* This same command can be sent to Canary by changing
'Google Chrome.app' to 'Google Chrome Canary.app' *)
do shell script "open -a 'Google Chrome.app' --args --disable-web-security --allow-running-insecure-content"
(* If you want to not use your current user in Chrome you can set --user-data-dir to point to /tmp
@mjohnsullivan
mjohnsullivan / MainActivity.java
Last active March 1, 2024 01:28
Android Wear activity that reads and displays sensor data from the device
package com.example.wear;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.support.wearable.view.WatchViewStub;
import android.util.Log;
@kmaida
kmaida / dynamicPagRepeatAngular.html
Last active December 13, 2023 14:37
AngularJS - Dynamic pagination on ng-repeat with search/filtering. Use with ui.bootstrap
<!DOCTYPE HTML>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Dynamic Pagination w/ Filtering</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Kim Maida">
<!-- JS Libraries -->
@allenhwkim
allenhwkim / gist:be508558869f322e7697
Created October 22, 2014 14:48
Angular Google Maps Fit Bounds
<!doctype html>
<html ng-app="myapp">
<head>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="http://code.angularjs.org/1.2.25/angular.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<script>
var app = angular.module('myapp', ['ngMap']);
app.controller('MyCtrl', function($scope) {
$scope.positions = [ [-24,132] ,[-25,131] ,[-26,130] ];
@PomepuyN
PomepuyN / SettingsAdapter.java
Last active June 5, 2018 09:02
Functional example of WearableListView
public class SettingsAdapter extends WearableListView.Adapter {
private final Context context;
private final List<SettingsItems> items;
public SettingsAdapter(Context context, List<SettingsItems> items) {
this.context = context;
this.items = items;
}
@rmondello
rmondello / gist:b933231b1fcc83a7db0b
Last active April 5, 2024 07:10
Exporting (iCloud) Keychain and Safari credentials to a CSV file

Exporting (iCloud) Keychain and Safari credentials to a CSV file

Update (October 2021)

Exporting password + one-time code data from iCloud Keychain is now officially supported in macOS Monterey and Safari 15 (for Monterey, Big Sur, and Catalina). You can access it in the Password Manager’s “gear” icon (System Preferences > Passwords on Monterey, and Safari > Passwords everywhere else), or via the File > Export > Passwords... menu item). You shouldn't need to hack up your own exporter anymore.

Original, Obsolete Content (2014)

After my dad died, I wanted to be able to have access any of his online accounts going forward. My dad was a Safari user and used iCloud Keychain to sync his credentials across his devices. I don’t want to have to keep an OS X user account around just to access his accounts, so I wanted to export his credentials to a portable file.