Skip to content

Instantly share code, notes, and snippets.

View rchacon's full-sized avatar
🥑

Raul Chacon rchacon

🥑
  • Syracuse, New York
View GitHub Profile
@rchacon
rchacon / vimeo.html
Last active August 29, 2015 14:02
Using jQuery and vimeo's REST API to fetch a video's description
<div id="video-container"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var vimeoId = 98357626;
// get description of video from vimeo
$.getJSON("http://vimeo.com/api/v2/video/" + vimeoId + ".json", function (videos) {
$("#video-descr").html(videos[0].description);
});
@rchacon
rchacon / Program.cs
Created August 18, 2014 20:55
REST API Example built with ASP.NET MVC 4
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
namespace api_v1_csharp.Models.academics
{
public class Program
{
@rchacon
rchacon / Web.config
Created August 24, 2014 06:13
IIS Rewrite Rule to redirect /route-name.aspx to /route-name
<rule name="redirect-aspx" enabled="true" stopProcessing="true">
<match url="(.*).aspx$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="http://library.morrisville.edu/{R:1}" appendQueryString="true" />
</rule>
@rchacon
rchacon / vb-import.sublime-snippet
Created October 22, 2014 15:54
VB: Import Namespace #snippet
<snippet>
<content><![CDATA[
<%@ Import Namespace="${1:}" %>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>imp</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.asp</scope>
</snippet>
@rchacon
rchacon / vb-include.sublime-snippet
Created October 23, 2014 14:35
VB: Include File #snippet
<snippet>
<content><![CDATA[
<!-- #include file = "${1:}" -->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>include</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.asp</scope>
</snippet>
@rchacon
rchacon / compress.py
Created December 20, 2014 04:14
Count occurrences of letters in string.
"""
hhhhh aaaaa => h5 5a5
"""
def compress_sentence(sentence):
prev_letter = sentence[0]
frequency = 1
output = ''
for letter in sentence[1:]:
@rchacon
rchacon / .htaccess
Created January 12, 2015 03:00
Python on 1and1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /mysite/application.cgi/$1 [L]
@rchacon
rchacon / UsersRepository.cs
Created March 13, 2015 03:19
Validate and Search against Active Directory
namespace api_v1_csharp.Models.ldap
{
using System;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.DirectoryServices.AccountManagement;
using System.Collections.Generic;
public class UsersRepository : IUsersRepository
{
@rchacon
rchacon / README.md
Last active August 29, 2015 14:17
Resharper Code Snippets

my resharper snippets

@rchacon
rchacon / test_xmas.py
Last active February 9, 2016 23:50
Dependency Injection and Partial Mocking
class XmasTest(unittest.TestCase):
@mock.patch('xmas.date')
def test_days_til_xmas_when_xmas(self, mock_date):
mock_date.today.return_value = date(2020, 12, 25)
mock_date.side_effect = lambda *args, **kw: date(*args, **kw)
days = days_til_xmas()
self.assertEqual(days, 0)