Skip to content

Instantly share code, notes, and snippets.

int[] amount = new int[12]; // amount of rain at every month
int yearSum = 0, halfSum1 = 0, halfSum2 = 0, overTheAverage = 0;
double yearAvg, halfAvg1, halfAvg2;
for (int i = 0; i < amount.Length; i++)
{
Console.WriteLine("enter the amount of rain for " + (i + 1) + "th month:");
amount[i] = int.Parse(Console.ReadLine());
yearSum += amount[i];
@Gofilord
Gofilord / gist:ee2336d3a1ec2fca3b78
Created November 4, 2014 15:17
Creating a chain without array
Node<Integer> lastNode = new Node<Integer>(rndVal, null);
Node<Integer> nextNode = new Node<Integer>(rndVal - 1, lastNode);
for (int i = rndVal - 2; i >= 0; i--)
nextNode = new Node<Integer>(i, nextNode);
// print
@Gofilord
Gofilord / Main.java
Created November 4, 2014 15:18
Create node chain without array
Node<Integer> lastNode = new Node<Integer>(rndVal, null);
Node<Integer> nextNode = new Node<Integer>(rndVal - 1, lastNode);
for (int i = rndVal - 2; i >= 0; i--)
nextNode = new Node<Integer>(i, nextNode);
import java.awt.Point;
public class Main {
public static void printMatrix(int[][] mat) {
for (int i = 0; i < mat.length; i++)
{
for (int j = 0; j < mat.length; j++)
System.out.print(mat[i][j] + " ");
System.out.print("\n");
}
@Gofilord
Gofilord / Tal
Created December 19, 2014 13:21
public static void main(string[] args)
{
// let's say there are 10 boys, 11 girls and each girl gets to choose 5
const int BOY_AMOUNT = 10;
const int GIRL_AMOUNT = 11;
const int CHOICE_AMOUNT = 5;
// indexes are serial numbers and the values are their scores
int[] boys = new int[BOY_AMOUNT];
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
}
});
public void onCreate(...) {
...
SwipeDismissListViewTouchListener.DismissCallbacks dismissCallbacks = new SwipeDismissListViewTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
return true;
}
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions) {
@Gofilord
Gofilord / app.js
Last active April 11, 2021 12:24
Sending a mail via ajax with a captcha
$('#submit').click(function(e) {
// e.preventDefault();
console.log('clicked submit');
var $errors = $('#errors'),
$status = $('#status'),
name = $('#name').val().replace(/<|>/g, ""), // no xss
email = $('#email').val().replace(/<|>/g, ""),
msg = $('#message').val().replace(/<|>/g, "");
var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
// constants
var CLIENT_ID = '312634809793-4d4baf8u62ck2l4s7uucamp175m9q49p.apps.googleusercontent.com';
var CLIENT_SECRET = 'My Client Secret';
var REDIRECT_URL = 'http://localhost:3000/oauth2callback'; // registered with the developer console
var oauth2Client = new OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);