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
#ow do you define a class, instance and global variables | |
#simple class. Scope is defined until the 'end' keyword | |
#at the bottom of the file. | |
class MyPost | |
#global variables are defined by being in all caps | |
#the interpreter knows this is not to be modified. | |
MY_POST_DATE = "Saturday, December 19" | |
#this represent the '.new' method we call when creating a new |
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
#How modules are defined and how they provide the mixin functionality | |
module Utils | |
#this method belongs to the namespace defined by the module | |
#It will not go out of this scope | |
def self.nil(obj) | |
obj.nil? | |
end | |
#this one will be made available to any class that require/include |
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
package blog.pedro.gabriel.dev; | |
public class Main { | |
public static void main(String[] args) { | |
Person femalePerson = new Female("Female"); | |
Person malePerson = new Male("Male"); | |
try{ | |
Person person = (Female) femalePerson; | |
Person person2 = (Male) malePerson; |
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
public class Display extends AppCompatActivity { | |
private static final String COUNTER_KEY = "counter_key"; | |
private static final java.lang.String LAST_ORIENTATION_KEY = "orient_key"; | |
private int mHowManyRotations; | |
private int mLastOrientation; | |
private TextView mDisplay; |
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 strict"; | |
function mapReduce(arr, mapProc, reduceProc, seed){ | |
return arr.map(mapProc).reduce(reduceProc, seed); | |
} | |
//this way we can apply the function to every array we create in our programm. | |
Array.prototype.mapReduce = function (mapProc, reduceProc, seed){ | |
return this.map(mapProc).reduce(reduceProc, seed); | |
} |
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
using System; | |
using System.Net.Http; | |
using System.Web.Http; | |
namespace TypesOfRouting | |
{ | |
[RoutePrefix("api/message")] | |
public class AttrController : ApiController | |
{ |
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
namespace TypesOfRouting | |
{ | |
public class HelloController : ApiController | |
{ | |
public String Get() | |
{ | |
return "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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
namespace writereadfiles | |
{ | |
class Program | |
{ | |
private const string NewFilePath = "new_file.txt"; | |
private const string FileToReadPath = "file_to_read.txt"; |
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
package com.company; | |
import java.io.BufferedWriter; | |
import java.io.IOException; | |
import java.nio.charset.Charset; | |
import java.nio.file.Files; | |
import java.nio.file.LinkOption; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.util.Optional; |
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
namespace WebApplication1.Controllers | |
{ | |
public class HomeController : ApiController | |
{ | |
//Complex types come from the body. We must explicitly say this one comes from the URI. | |
public IHttpActionResult GetIndex([FromUri] Interval interval) | |
{ | |
if (interval.After == -1 || interval.Before == -1) return BadRequest("Invalid Parameters"); | |
return interval.isIntervalCorrect() ? | |
(IHttpActionResult) Ok("Correct Interval") : Ok("Incorrect Interval"); |
OlderNewer