Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
using namespace std;
int main() {
cout << "x postfix = " << x++ << endl;
cout << "x after postfix " << x << endl;
cout << "x prefix = " << ++x << endl;
cout << "x after prefix " << x << endl;
}
URL url = new URL("http://yoururl.com");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setReadTimeout(10000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
Uri.Builder builder = new Uri.Builder()
.appendQueryParameter("firstParam", paramValue1)
var totalSec = yourTime / 1000;
var minutes = parseInt( totalSec / 60 ) % 60;
var seconds = totalSec % 60;
var result = (hours < 10 ? "0" + hours : hours) + "-" + (minutes < 10 ? "0" + minutes : minutes) + "-" + (seconds < 10 ? "0" + seconds : seconds);
// Chrome extension button / popup / requester
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(
tab.id, // id of the tab to send a request to.
{method: "getHighlighted", name: "John"}, // data to send to the tab
function(response) { // function to execute when the tab responds.
if (response.method == 'getHighlighted') {
chrome.setClipboard(response.data); // Something like this.
// response.data contains our highlighted text.
}
var Student = function(name, course, pace) {
this.name = name;
this.course = course;
this.pace = pace;
this.printStudent = function() {
console.log(this.name, this.course, this.pace);
}
}
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World");
Float x = 5;
try {
Float.parseInt(x);
} catch (ParseException e) {
// Required to catch this because of throws statement in method declaraction
System.out.println("Parse exception");
Name: John Doe
Bloc Program / length: Android, 36-week
App Name: MoneyLens
Description:
This app blah blah
How did you come up with the idea?
I’m a blah blah and I blah therefore blah
URL requestUrl = new URL(fullURLRequest);
HttpUrlConnection urlConnection = (HttpURLConnection) requestUrl.openConnection();
InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder jsonString = new StringBuilder();
// You only want to call readLine once - the assignment will fail once readLine is null;
// calling ReadLine twice will cause an error.
while (String line = bufferedReader.readLine()) {
jsonString.append(line);
}
Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
this.collidesWith = function(otherObject) {
var width = 2*this.radius;
var height = 2*this.radius;
var translatedX = this.x - radius;
var translatedY = this.y - radius;
if (translatedX < otherObject.x + otherObject.width &&
translatedX + width > otherObject.x &&
translatedY < otherObject.y + otherObject.height &&
height + translatedY > otherObject.y) {