Skip to content

Instantly share code, notes, and snippets.

View Calvein's full-sized avatar
🐶

François Robichet Calvein

🐶
View GitHub Profile
@Calvein
Calvein / index.styl
Created March 1, 2015 06:03
Basic css switches (I just needed a checkbox, you might too).
switchHeight = 15px
switchPadding = 2px
switchWidth = 25px
.switch
position absolute
height switchHeight
width switchWidth
top 4px
right 5px
border-top-left-radius 25% 50%
@Calvein
Calvein / index.coffee
Created January 9, 2015 05:27
Generate readable string
generateTitle = ->
v = 'aeiouy'
c = 'bcdfghjklmnpqrstvwxz'
text = ''
for i in [0..6]
group = if i % 2 then v else c
letter = group.charAt(Math.floor(Math.random() * group.length))
if i is 0
letter = letter.toUpperCase()
div = document.createElement('div')
fakeSvg = '<svg>' + markerIcon + '</svg>'
div.innerHTML = '' + fakeSvg
for el in Array::slice.call(div.childNodes[0].childNodes)
marker.node().appendChild(el)
@Calvein
Calvein / gist:cafd35221b40b741e0da
Created October 27, 2014 22:46
Download all files from a basecamp "View all of these files at once"
var as = document.querySelectorAll('br + a')
for (var i = 0, len = as.length; i < len; i++) {
var a = _ref[i]
a.setAttribute('download', a.textContent)
a.click()
}
@Calvein
Calvein / README.md
Created July 5, 2014 09:43
D3 map animation

Map animation in D3.

@Calvein
Calvein / app.coffee
Last active August 29, 2015 14:03
Little map animation in D3 (needs https://www.npmjs.org/serveur)
# Size of the map
size = 240
# Zoom level to see all Australia
startScale = 330
# Zoom level when zoomed
zoomedScale = 1330
# Transition duration
duration = 400
projection = d3.geo.mercator()
@Calvein
Calvein / getObjects.js
Created April 29, 2014 04:49
Get all objects from a parse class
// Returned promise
var promise = new Parse.Promise()
// Error function
var error = function() {
console.error('Error:', arguments)
// Break it
response.error('Query failed, check logs')
}
@Calvein
Calvein / colors.coffee
Last active August 29, 2015 13:56
Get the average of colors (#123456)
averaveColor = (colors) ->
d2h = (d) -> d.toString(16)
h2d = (h) -> parseInt(h, 16)
r = g = b = 0
for color in colors
r += h2d(color.slice(1, 3))
g += h2d(color.slice(3, 5))
b += h2d(color.slice(5))
@Calvein
Calvein / font-size.js
Last active August 30, 2022 00:46
Change font-size of an element if text is bigger than the content.
// Resize el if too long
fontSize = parseInt(el.style.fontSize)
while (el.offsetWidth < el.scrollWidth)
el.style.fontSize = --fontSize
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.