Skip to content

Instantly share code, notes, and snippets.

View samirahmed's full-sized avatar

Samir Ahmed samirahmed

  • Snap Inc
  • Los Angeles, CA
View GitHub Profile
@samirahmed
samirahmed / crosssite.cs
Last active March 21, 2017 16:42
Cross Site Json In MVC and WebAPI
// taken from http://stackoverflow.com/questions/6290053/setting-access-control-allow-origin-in-asp-net-mvc-simplest-possible-method
// For MVC
public class AllowCrossSiteJsonAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*");
base.OnActionExecuting(filterContext);
}
@samirahmed
samirahmed / errorcodes.m
Created November 13, 2014 18:13
NSURLErrorDomain codes
kCFURLErrorUnknown = -998,
kCFURLErrorCancelled = -999,
kCFURLErrorBadURL = -1000,
kCFURLErrorTimedOut = -1001,
kCFURLErrorUnsupportedURL = -1002,
kCFURLErrorCannotFindHost = -1003,
kCFURLErrorCannotConnectToHost = -1004,
kCFURLErrorNetworkConnectionLost = -1005,
kCFURLErrorDNSLookupFailed = -1006,
kCFURLErrorHTTPTooManyRedirects = -1007,
@samirahmed
samirahmed / sample.cs
Created November 13, 2014 14:13
https redirect
protected void Application_BeginRequest()
{
// Redirect to https always
if (!Context.Request.IsLocal && !Context.Request.IsSecureConnection)
Response.Redirect(Context.Request.Url.ToString().Replace("http:", "https:"));
}
@samirahmed
samirahmed / gist:c4514fab97b223ab0ce7
Created August 4, 2014 20:02
stacktrace from running 2 rivers ...
[2014-08-04 13:01:45,041][ERROR][de.saly.elasticsearch.river.imap.IMAPRiver] Unable to start IMAPRiver due to org.quartz.ObjectAlreadyExistsException: Unable to store Trigger with name: 'intervaltrigger' and group: 'group1', because one already exists with this identification.
org.quartz.ObjectAlreadyExistsException: Unable to store Trigger with name: 'intervaltrigger' and group: 'group1', because one already exists with this identification.
at org.quartz.simpl.RAMJobStore.storeTrigger(RAMJobStore.java:415)
at org.quartz.simpl.RAMJobStore.storeJobAndTrigger(RAMJobStore.java:252)
at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:886)
at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249)
at de.saly.elasticsearch.river.imap.IMAPRiver.start(IMAPRiver.java:283)
at org.elasticsearch.river.RiversService.createRiver(RiversService.java:148)
at org.elasticsearch.river.RiversService$ApplyRivers$2.onResponse(RiversService.java:275)
at org.elasticsearch.river.RiversService$ApplyRiver
@samirahmed
samirahmed / fix issue
Created April 4, 2014 02:02
add this link to fix cross domain issues
@@ -42,7 +42,8 @@ function autocomplete() {
theme: 'facebook',
hintText: null,
searchingText: '...',
- preventDuplicate: true
+ preventDuplicate: true,
+ crossDomain: false
});
}
@samirahmed
samirahmed / html_xpath.cs
Created October 21, 2013 04:34
Html/Css queries to Xpath helper methods in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CssPath
{
public static class By
{
@samirahmed
samirahmed / Renew_IP_OSX.sh
Last active December 11, 2015 11:18
run these commands to renew your ip on OSX. The curl ip.appspot.com will tell you your external IP, run before and after to ensure there has been a change
curl ip.appspot.com
sudo ipconfig set en0 BOOTP
sudo ipconfig set en0 DHCP
curl ip.appspot.com
@samirahmed
samirahmed / port_flag_scan.py
Created October 13, 2012 21:12
Response Difference In With Different Flags
import sys
import os
import subprocess
def execute( command):
result = ""
try:
result = os.popen( command ).read()
except Exception: