Skip to content

Instantly share code, notes, and snippets.

@BorisKozo
BorisKozo / app.js
Created April 2, 2017 09:06
Getting Tableau data from Node.js
//We use this code to retrieve data directly from Tableau server 10.1 from our Node.js server
//This is just a simplified example, not the actual code :)
// You need to fill in all the things in < >
const tableauServer = 'https://<IP OF YOUR SERVER>/trusted';
const username = '<username of a valid user to view the data>';
const reportPath = '/views/<WORKBOOK>/<view>';
const request = require('request-promise-native');
//This is optional, you can add filter parameters directly into the URL
//Check if you need to URI encode the parameter value
@zappycode
zappycode / NSImageToJpeg.swift
Last active December 31, 2023 03:40
Coverting an NSImage into JPEG Data
func jpegDataFrom(image:NSImage) -> Data {
let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil)!
let bitmapRep = NSBitmapImageRep(cgImage: cgImage)
let jpegData = bitmapRep.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:])!
return jpegData
}
@noelboss
noelboss / git-deployment.md
Last active May 16, 2024 20:41
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@scottjehl
scottjehl / noncritcss.md
Last active August 12, 2023 16:57
Comparing two ways to load non-critical CSS

I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.

TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/


For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).

Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:

@marcoarment
marcoarment / ATPLogoView.m
Created April 29, 2014 21:07
Source for the Accidental Tech Podcast (ATP) T-Shirt
// Source for the Accidental Tech Podcast (ATP) T-Shirt:
// http://www.marco.org/2014/04/29/atp-shirts
//
// By Marco Arment, April 28, 2014. MIT license.
@implementation ATPLogoView
- (void)drawRect:(CGRect)rectIgnored
{
NSString *fontName = @"MyriadPro-Semibold";
@waterlink
waterlink / devise.rb
Created March 16, 2014 15:19
Rspec Devise helper with support for routing :authenticated and :unauthenticated tests
# spec/support/devise.rb
module Devise::RoutingTestHelpers
attr_accessor :request
def initialize(*args)
@request ||= Hashie::Mash.new env: {}
super(*args)
end
@domenic
domenic / q-mongoose-so.js
Last active August 24, 2017 05:49
Q + Mongoose from StackOverflow
var mongoose = require('mongoose');
mongoose.connect('mongo://localhost/test');
var conn = mongoose.connection;
var users = conn.collection('users');
var channels = conn.collection('channels');
var articles = conn.collection('articles');
var insertUsers = Q.nfbind(users.insert.bind(users));
var insertChannels = Q.nfbind(channels.insert.bind(channels));
#!/bin/sh
# on osx lion, this is a great way to listen to this in the background. make sure to download and
# install sangeeta and tom and karen in system preferences. feel free to change the voices to your
# suiting, but sangeeta is a fave of mine for almost everything.
say -v Sangeeta "hey"
say -v Sangeeta "I'm sorry"
say -v Sangeeta "how would you like me to describe backbone?"
say -v Sangeeta "let's work this out for once and for all :)"
For those folks not already hanging out in #documentcloud... here's the log of this afternoon's Ember/Backbone politics discussion.
12:21 PM <wycats> jashkenas: hey
12:21 PM <wycats> jashkenas: I'm sorry
12:21 PM <wycats> how would you like me to describe backbone?
12:21 PM <wycats> let's work this out for once and for all :)
12:21 PM <wycats> I'm definitely not intentionally saying incorrect things about backbone
12:22 PM • knowtheory gets out popcorn
12:24 PM <jashkenas> don't worry about it too much -- I'm just not terribly pleased with backbone being continued to be used as the strawman...
12:24 PM <wycats> jashkenas: I am worried about it a lot
@codeswimmer
codeswimmer / CustomView_drawGradient.m
Created November 16, 2011 22:17
iOS: Draw gradient fill
-(void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrnetContext();
CGGradientRef gradient = [self gradient];
CGPoint startPoint = CGPointMake(CGRectGetMidX(self.bounds), 0.0);
CGPoint endPoint = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMaxY(self.bounds));
CGContextDrawLinearGradient(context, gradient, startPoint, endPoint);
}
-(CGGradientRef)gradient