Skip to content

Instantly share code, notes, and snippets.

@mderazon
mderazon / .jscsrc
Last active August 29, 2015 14:06
sublime-text setup
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
@mderazon
mderazon / node_modules.sh
Last active August 29, 2015 14:17
fav node modules
npm install -g trash mocha gulp nodemon iojs-dep-check
@mderazon
mderazon / config.sh
Last active August 29, 2015 14:23
automatically create a tag for package version bump
# file: .git/config
# this pushes every branch that's already there, plus tags. It does not force push, and it does not push branch that we didn't push manually.
[remote "origin"] # or whatever it is named
url = ...
push = :
push = +refs/tags/*:refs/tags/*
@mderazon
mderazon / actionbar_search.xml
Last active December 23, 2015 15:09
The AutoCompleteTextView that goes into the ActionBar
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal"
android:focusable="true" >
<AutoCompleteTextView
android:id="@+id/search_box"
android:layout_width="fill_parent"
@mderazon
mderazon / search_item.xml
Last active December 23, 2015 15:09
search item
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="gravity" >
<TextView
android:id="@+id/search_item_venue_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@mderazon
mderazon / main activity search.java
Last active December 23, 2015 15:09
how to put the search box in the actionbar
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ......
// ......
ActionBar actionBar = getSupportActionBar(); // you can use ABS or the non-bc ActionBar
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME
| ActionBar.DISPLAY_HOME_AS_UP); // what's mainly important here is DISPLAY_SHOW_CUSTOM. the rest is optional
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@mderazon
mderazon / venueFilter.java
Last active December 23, 2015 15:18
venue filter
private class VenueFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
List<JSONObject> list = new ArrayList<JSONObject>(venues);
FilterResults result = new FilterResults();
String substr = constraint.toString().toLowerCase();
// if no constraint is given, return the whole list
if (substr == null || substr.length() == 0) {
result.values = list;
@mderazon
mderazon / search adapter.java
Created September 21, 2013 21:20
adapter for autocomplete search box
// adapter for the search dropdown auto suggest
ArrayAdapter<JSONObject> searchAdapter = new ArrayAdapter<JSONObject>(this, android.R.id.text1) {
private Filter filter;
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = this.getLayoutInflater().inflate(R.layout.search_item, parent, false);
}
TextView venueName = (TextView) convertView
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
$('textarea[data-editor]').each(function () {
@mderazon
mderazon / 0_reuse_code.js
Created October 30, 2013 09:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console