Skip to content

Instantly share code, notes, and snippets.

View mahizsas's full-sized avatar

MAHIZ mahizsas

View GitHub Profile
public class EmbeddedContent : HttpContent
{
private readonly Stream _Stream;
public EmbeddedContent(Type locatorType, string filename, MediaTypeHeaderValue contentType = null)
{
Headers.ContentType = contentType ?? new MediaTypeHeaderValue("application/octet-stream");
public class ImageContent : HttpContent
{
private Image _image;
public ImageContent(Image image, MediaTypeHeaderValue mediatype)
{
_image = image;
Headers.ContentType = mediatype;
}
public class FileContent : HttpContent
{
private const int DefaultBufferSize = 1024 * 64;
private readonly string _fileName;
private readonly FileInfo _fileInfo;
public FileContent(string fileName, MediaTypeHeaderValue contentType = null)
{
Headers.ContentType = contentType ?? new MediaTypeHeaderValue("application/octet-stream");
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.
app.directive('infiniteScroll', [
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
return {
link: function(scope, elem, attrs) {
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
$window = angular.element($window);
elem.css('overflow-y', 'scroll');
elem.css('overflow-x', 'hidden');
elem.css('height', 'inherit');
scrollDistance = 0;
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) {
$httpProvider.responseInterceptors.push([
'$q', '$templateCache', 'activeProfile',
function($q, $templateCache, activeProfile) {
// Keep track which HTML templates have already been modified.
var modifiedTemplates = {};
// Tests if there are any keep/omit attributes.
var HAS_FLAGS_EXP = /data-(keep|omit)/;
/**
* Example of using an angular provider to build an api service.
* @author Jeremy Elbourn ([email protected])
*/
/** Namespace for the application. */
var app = {};
/******************************************************************************/
.filter('timeago', function () {
/*
* time: the time
* local: compared to what time? default: now
* raw: wheter you want in a format of "5 minutes ago", or "5 minutes"
*/
// parse string date to milliseconds
// Note: months are 0-based
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.WebPages;
namespace DynamicHtmlTemplates
{
public class Templates : System.Dynamic.DynamicObject
{
public class MobileServiceRequestHelper<T> where T : class
{
private string tableEndpoint;
private string applicationKey;
private HttpClient client;
public MobileServiceRequestHelper(string tableName)
{
tableEndpoint = ConfigurationManager.AppSettings["TableEndpoint"] + tableName ;
applicationKey = ConfigurationManager.AppSettings["X-ZUMO-APPLICATION"];
client = new HttpClient();