Skip to content

Instantly share code, notes, and snippets.

View okaram's full-sized avatar

Orlando Karam okaram

View GitHub Profile
void Main()
{
Person p=new Person(){Name="Orlando",Age=10};
Console.WriteLine(p.GetType().GetProperties());
Console.WriteLine(p.GetType().GetProperties().Select(x=>x.GetMethod.Invoke(p,null)));
}
// Define other methods and classes here
class Person {
public string Name {get; set;}
public class Puppy {
// instance variables; private
private String _name;
private int _age;
// constructor
public Puppy (String name, int age)
{
// constructor is called on a specific instance; let's modify that instance's variables
_name=name;
sales=sc.textFile("sales_*.txt").map(lambda x:x.split('\t'))
{
"sheets": [
{
"title": "P&P",
"queries": [
{
"db_driver": "psycopg2",
"db_conn_str": "dbname=curri user=curri",
"title": "People",
"query": "SELECT * FROM Person"
@okaram
okaram / DFA1.scala
Last active August 29, 2015 14:00
Automatas in Scala
class DFA[StateType]
(
val Q:Set[StateType],
val F:Set[StateType],
val q0:StateType,
val delta: (StateType,Char)=>StateType,
val Sigma:Set[Char]
)
{
...
@okaram
okaram / contacts.xml
Last active August 29, 2015 13:58
Super Quick Linq to XML
<contacts>
<contact id="1">
<firstName>Orlando</firstName>
<lastName>Karam</lastName>
</contact>
<contact id="2">
<firstName>Lina</firstName>
<lastName>Colli</lastName>
</contact>
</contacts>
@okaram
okaram / ExensionMethods.cs
Created March 7, 2014 00:47
Playing with extension methods
public static class MyExtensions
{
public static System.TimeSpan Months(this Int32 x)
{
return System.DateTime.Today.AddMonths(x) - System.DateTime.Today;
}
public static System.TimeSpan Years(this Int32 x)
{
return System.DateTime.Today.AddYears(x) - System.DateTime.Today;
@okaram
okaram / Query1.sql
Last active December 29, 2015 05:39
XML SQL Queries
SELECT id,name, SkillsXml.query('/skills/skill[1]')
FROM People
@okaram
okaram / PersonController.cs
Created November 23, 2013 20:01
Web API With Dapper
using Dapper;
namespace DapperCleanDemo.Controllers
{
public class PeopleController : ApiController
{
public IEnumerable<dynamic> GetResultById(string id)
{
using (var conn = new SqlConnection(@"Server=localhost\sqlexpress;Database=XmlTest;Trusted_Connection=True"))
{
@okaram
okaram / accepts.cpp
Created June 7, 2013 18:10
Finite State Machines (Automatas) in C++
bool accepts(string str)
{
return contains(F,delta_hat(q0,str));
}