Skip to content

Instantly share code, notes, and snippets.

View japj's full-sized avatar

Jeroen Janssen japj

View GitHub Profile
@KirillOsenkov
KirillOsenkov / AddGeneratedFile.csproj
Last active March 8, 2024 14:18
Sample of generating a .cs file during build and adding it to the compilation
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<GeneratedText><![CDATA[
using System%3B
@GoEddie
GoEddie / targetSqlVersion.cs
Created May 4, 2017 20:42
If you have an SSDT project in visual studio and want to get the version of sql it is targetting because everything is internal :( do this!
string GetTargetSqlServerVersion(){
var dte = (DTE)GetService(typeof(DTE));
var project = dte.ActiveDocument.ProjectItem.ContainingProject;
return project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project)).GetType().GetProperty("DatabaseSchemaProvider").GetValue(project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project))).GetType().GetProperty("Platform").GetValue(project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project)).GetType().GetProperty("DatabaseSchemaProvider").GetValue(project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project))))
}
@domenic
domenic / portable-node.md
Created May 25, 2012 21:03
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation

@TooTallNate
TooTallNate / README.md
Created November 16, 2011 00:57
A C header file to make your node bindings backwards and forwards compatible that use eio_custom()

node_async_shim.h

Use this header file to conditionally invoke eio_custom() or uv_queue_work(), depending on the node version that the module is being compiled for.

See the usage.cc file for a partial example.

Comments, forks, and improvements are welcome!

@mattpodwysocki
mattpodwysocki / jsconf-eu-2011.md
Created October 1, 2011 13:40
JSConf.EU Slides
@blindsey
blindsey / github_post_commit.js
Created August 27, 2011 06:17
node.js auto deploy scripts
Steps:
0. Checkout your git repo from the server (I use /var/www/carbonite)
1. Upload both of these files to the same directory on your server
2. chmod +x restart_node.sh
3. nohup node github_post_commit.js 2>&1 >> github_post_commit.log &
4. In the github admin for your repo, set a post commit hook to the url http://<your host>:8080/
5. Make a commit to your repo
6. Point a browser at http://<your host>:8080/ and you should see the commit
@thejh
thejh / bot.coffee
Created August 14, 2011 21:38
My IRC bot, jhbot
coffee = require 'coffee-script'
https = require 'https'
npm = require 'npm'
Irc = require 'irc-js'
cradle = require 'cradle'
{GitHubApi} = require 'github'
request = require 'request'
gitHubApi = new GitHubApi()
githubIssueApi = gitHubApi.getIssueApi()
githubObjectApi = gitHubApi.getObjectApi()
var follow = require("follow")
var seen = {}
follow({ db: "http://isaacs.ic.ht/registry"
, since: 20267
, include_docs: true }, function (er, update) {
if (er) throw er
var doc = update.doc
@japj
japj / custommain.js
Created July 16, 2011 20:00 — forked from creationix/custommain.js
A proposed hook into node.js to make deploying node based applications easy and not require re-compiles.
startup.customRuntimeMain = function () {
var path = NativeModule.require('path');
var custom = path.resolve(process.cwd(), process.argv[0] + ".js");
if (!path.existsSync(custom)) return;
process.argv[1] = custom;
};