Skip to content

Instantly share code, notes, and snippets.

View Daniel15's full-sized avatar
💭
Busy

Daniel Lo Nigro Daniel15

💭
Busy
View GitHub Profile
public abstract class ConfigurationElementCollection<TKey, TElement>
: ConfigurationElementCollection,
IList<TElement>, IDictionary<TKey, TElement>
where TElement : ConfigurationElement, new()
{
protected override ConfigurationElement CreateNewElement()
{
return new TElement();
}
@Daniel15
Daniel15 / gist:7653825
Created November 26, 2013 05:20
Basic AJAX loading
/**
* Does an AJAX load of the specified URL
*
* @param {String} url URL to load
* @param {Object} data Hash of data to send in querystring
* @param {Function} callback Function to call once request returns
*/
function load(url, data, callback) {
if (data) {
var params = Object.keys(data)
@Daniel15
Daniel15 / gist:7969014
Last active May 27, 2017 15:42
Item/List classes in React
var Item = React.createClass({
render: function() {
return(
<li>
... Item goes here ...
<input type="checkbox" checked={this.props.selected} onChange={this.onChange} />
</li>
);
},
onChange: function(event) {
@Daniel15
Daniel15 / dialog.js
Created January 8, 2014 18:17
Bootstrap dialog in React
var Dialog = React.createClass({
getInitialState: function() {
return {
className: 'modal fade'
};
},
show: function() {
this.setState({ className: 'modal fade show' });
setTimeout(function() {
this.setState({ className: 'modal fade show in' });
Jint.dll!Jint.Native.Object.ObjectInstance.DefineOwnProperty(string propertyName, Jint.Runtime.Descriptors.PropertyDescriptor desc, bool throwOnError) Line 362 C#
Jint.dll!Jint.Native.Argument.ArgumentsInstance.DefineOwnProperty(string propertyName, Jint.Runtime.Descriptors.PropertyDescriptor desc, bool throwOnError) Line 147 C#
Jint.dll!Jint.Native.Argument.ArgumentsInstance.CreateArgumentsObject(Jint.Engine engine, Jint.Native.Function.FunctionInstance func, string[] names, Jint.Native.JsValue[] args, Jint.Runtime.Environments.EnvironmentRecord env, bool strict) Line 70 C#
Jint.dll!Jint.Engine.DeclarationBindingInstantiation(Jint.DeclarationBindingType declarationBindingType, System.Collections.Generic.IList<Jint.Parser.Ast.FunctionDeclaration> functionDeclarations, System.Collections.Generic.IList<Jint.Parser.Ast.VariableDeclaration> variableDeclarations, Jint.Native.Function.FunctionInstance functionInstance, Jint.Native.JsValue[] arguments) Line 672 C#
Jint.dll!Jint.Native.Function.ScriptFunctionInstance
at scanComment (http://localhost/temp/JSXTransformer.js:6369:19)
at advance (http://localhost/temp/JSXTransformer.js:2988:13)
at lex (http://localhost/temp/JSXTransformer.js:3059:21)
at parseNonComputedProperty (http://localhost/temp/JSXTransformer.js:4267:21)
at http://localhost/temp/JSXTransformer.js:7394:38
at parseNonComputedMember (http://localhost/temp/JSXTransformer.js:4279:16)
at trackLeftHandSideExpressionAllowCall (http://localhost/temp/JSXTransformer.js:7307:67)
at parsePostfixExpression (http://localhost/temp/JSXTransformer.js:4347:20)
at http://localhost/temp/JSXTransformer.js:7394:38
at parseUnaryExpression (http://localhost/temp/JSXTransformer.js:4411:16)
@Daniel15
Daniel15 / Tutorial.jsx
Created April 7, 2014 00:30
ReactJS.NET Tutorial v1
/** @jsx React.DOM */
var CommentBox = React.createClass({
loadCommentsFromServer: function() {
var xhr = new XMLHttpRequest();
xhr.open('get', this.props.url, true);
xhr.onload = function() {
var data = JSON.parse(xhr.responseText);
this.setState({ data: data });
}.bind(this);
xhr.send();
@Daniel15
Daniel15 / FaviconProgress.html
Last active November 9, 2023 21:33
Using Favicon as progress bar
<!DOCTYPE html>
<html>
<head>
<title>Example Page</title>
</head>
<body>
<p>This page uses the favicon as a progress bar. Try clicking the button.</p>
<button onclick="run()">Do something</button>
<script>
@Daniel15
Daniel15 / gist:11127778
Created April 20, 2014 23:18
ILMerge from MSBuild

Install ILMerge from NuGet Set assembly name to "Blah.original.dll"

Set Post-build event command line to:

"$(SolutionDir)packages\ilmerge.2.13.0307\ilmerge.exe" /keyfile:"$(SolutionDir)Key.snk" /out:"$(TargetDir)$(ProjectName).dll" "$(TargetPath)" "$(SolutionDir)lib\foo.dll" "$(SolutionDir)lib\bar.dll"

This will generate a "Blah.dll" with foo.dll and bar.dll merged into it.

@Daniel15
Daniel15 / fix.php
Created May 11, 2014 07:01
Fixing badly-encoded UTF-8 characters in MySQL database
<?php
// Go home PHP, you're drunk.
// No charset here
$old_db = new PDO('mysql:host=localhost;dbname=database', 'username', 'password');
$old_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Charset here
$new_db = new PDO('mysql:charset=utf8mb4;host=localhost;dbname=database2', 'username', 'password');
$new_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);