Skip to content

Instantly share code, notes, and snippets.

View Meligy's full-sized avatar

Meligy Meligy

View GitHub Profile
@zenorocha
zenorocha / .hyper.js
Last active November 12, 2023 15:13 — forked from millermedeiros/osx_setup.md
Setup macOS Sierra (10.12)
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 14,
// font family with optional fallbacks
@aaronpowell
aaronpowell / PreExecutingResult.cs
Created April 18, 2013 04:45
Execute a Razor view server side in a MVC project. I'm returning the HTML in a JSON blob for this example
public class PreExecutingResult : JsonResult {
private ViewResult viewResult;
private object model;
public PreExecutingResult(string viewName, object model) {
viewResult = new ViewResult {
ViewName = viewName
};
viewResult.ViewData.Model = model;
@addyosmani
addyosmani / headless.md
Last active July 18, 2023 18:47
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

@DamianEdwards
DamianEdwards / Program.cs
Created March 19, 2013 05:54
Demonstrates that SqlDependency notifications can occur concurrently with the command that set them up. This might cause issues in certain cases if the application isn't expecting multiple commands to be executed at the same time.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
namespace SqlDependencyConcurrency
{
class Program
{
private static readonly string _connectionString = "Data Source=(local);Initial Catalog=Sample;Integrated Security=SSPI;";
@shanestillwell
shanestillwell / directive.js
Created December 24, 2012 20:46
AngularJS update model upon input blur
function Main() {}
// override the default input to update on blur
angular.module('app', []).directive('ngModelOnblur', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attr, ngModelCtrl) {
if (attr.type === 'radio' || attr.type === 'checkbox') return;
@brendankowitz
brendankowitz / gist:4071660
Created November 14, 2012 11:36
Umbraco IHttpModule to switch to an optional [TemplateAlias]Mobile template when mobile devices are detected
using System;
using System.Linq;
using System.Web;
using Kowitz.Core.Module;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using ZeroProximity.DeviceDetection;
using umbraco;
using umbraco.cms.businesslogic.template;
[assembly: PreApplicationStartMethod(typeof(MobileRewriteModule), "Start")]
@evandrix
evandrix / README.md
Created September 11, 2012 00:06
Headless web browsers

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@jakcharlton
jakcharlton / .gitignore
Created September 12, 2011 11:48
Git ignore for VS
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
(function($){
$.widget("ui.mywidget", {
options: {
autoOpen: true
},
_create: function(){
// by default, consider this thing closed.