This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple web server that proxies a remote image | |
run: simple-server . $PORT | |
*/ | |
var http = require('http'); | |
var url = require('url'); | |
var request = require('request'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var board; | |
var heroCoord = new Array(2); // x,y | |
//print for our perspective | |
function showBoard() { | |
console.log(heroCoord); | |
var print = ''; | |
for(var y=board[0].length-1; y>=0; y--) { | |
for(var x=0; x<board.length; x++) { | |
if (heroCoord[0] == x && heroCoord[1] == y) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Hello World"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.*; | |
class Homework1 { | |
public static void main(String args[]) { | |
int[] testArray = new int[10]; | |
// exercise 1 | |
fillWithRandomIntegers(testArray, 0, 100); | |
printArray(testArray); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use SharedPreferences APIs for small collection of data | |
// 1. using key | |
SharedPreferences pref = anyContext.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE); | |
// 2. activity's default | |
SharedPreferences pref = getAcitivy().getPreferences(Copntext.MODE_PRIVATE); | |
// Write | |
SharedPreferences.Editor editor = pref.edit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fragment = nested sub-activity w/ its own layout and lifecycle. (modular section of an activity) | |
// fragment receives the same lifecycle callbacks as its parent activity does | |
public class ArticleFragment extends Fragment { | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
return inflater.inflate(R.layout.article_view, container, false); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Declaring the main "launcher" activity --> | |
<activity android:name=".MainActivity" android:label="@string/app_name"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onCreate(...) { | |
super.onCreate(savedInstanceState); | |
TextView tv = new TextView(this); | |
tv.setTextSize(40); | |
tv.setText("blah"); | |
setContentView(tv); // adds tv as the root view of the activity's layout | |
} |