Skip to content

Instantly share code, notes, and snippets.

View vmandic's full-sized avatar
🤠
chillin'

Vedran Mandić vmandic

🤠
chillin'
View GitHub Profile
@vmandic
vmandic / SubscribeToMailchimpListAJAX
Last active February 2, 2016 12:39
subscribe to mailchimp list with double opt in
function signupMailchimp() {
var d = "FIRSTNAME={0}&LASTNAME={1}&EMAIL={2}".format
(
encodeURIComponent($("#FirstName").val()),
encodeURIComponent($("#LastName").val()),
encodeURIComponent($("#Email").val())
);
if ($("form.login").valid()) {
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };
@vmandic
vmandic / ko-chosen.js
Created October 5, 2016 14:04 — forked from isDipesh/ko-chosen.js
Collection of Knockout.js custom bindings.
//http://stackoverflow.com/questions/13210663/how-to-order-knockout-bindings
ko.bindingHandlers.chosen = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
var allBindings = allBindingsAccessor();
var options = {default: 'Select one...'};
$.extend(options, allBindings.chosen)
$(element).attr('data-placeholder', options.default);
// Some common and useful extensions for vanilla.js, knockout.js and jquery.js.
if(ko && ko.extenders) {
ko.extenders.roundToDotQuater = function (target) {
if (mogy.options.roundDecimalsToQuaters) {
var result = ko.pureComputed({
read: target,
write: function (newValue) {
target((Math.round(Math.round10(newValue, 2) * 4) / 4).toFixed(2));
}
@vmandic
vmandic / ko-extension-limitedNumeric.ts
Created November 28, 2016 13:01
A knockout.js extension for a numberic observable. Limits the numeric observable to the provided min and max range args.
// requires knockout.js and jquery.js
// limits the numeric observable to the provided min and max range args
ko.extenders["limitedNumeric"] = (target: Ko.Observable<any>, args: any) => {
let settings: any = {
minValue: 1,
maxValue: null
};
$.extend(settings, args);
@vmandic
vmandic / DeliminatorSeparatedPropertyNamesContractResolver.cs
Created January 6, 2017 20:24 — forked from roryf/DeliminatorSeparatedPropertyNamesContractResolver.cs
Snake case (underscore separated) property name resolver for Newtonsoft.Json library
public class DeliminatorSeparatedPropertyNamesContractResolver : DefaultContractResolver
{
private readonly string _separator;
protected DeliminatorSeparatedPropertyNamesContractResolver(char separator) : base(true)
{
_separator = separator.ToString();
}
protected override string ResolvePropertyName(string propertyName)
@vmandic
vmandic / instagram-autoliker
Created February 1, 2017 17:09
Autolikes loaded instagram post from the browser dev tools.
document.querySelectorAll("span.coreSpriteHeartOpen").forEach(function(h, i){
setTimeout(function(){h.click()}, (i*1000)+Math.random()*4000)
});
# ER-REACT101 - DEMO SETUP GUIDE
There are two main parts in this demo setup, those are:
1. **setting up the project and build system**
2. **actually writing react**
## 1. The Setup
1. npm init
- in project root you will get a `package.json` file
reg add "HKLM\Software\Microsoft\Fusion" /v EnableLog /t REG_DWORD /d 0 /f
@vmandic
vmandic / GoogleAnalyticsApi.cs
Created September 29, 2017 13:49 — forked from 0liver/GoogleAnalyticsApi.cs
C# wrapper around the Google Analytics Measurement Protocol API
/* based on the docs at: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide */
/*
* LICENSE: MIT
* AUTOHR: oliver@teamaton.com
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;