Skip to content

Instantly share code, notes, and snippets.

View musicmunky's full-sized avatar

Tim Andrews musicmunky

View GitHub Profile
@MichaelPote
MichaelPote / himawari.ps1
Created February 3, 2016 19:11
Windows Powershell Script to download the latest image from the Himawari-8 satelite, combine the tiles into a single image, convert to jpg and then set as the desktop background.
#
# Himawari-8 Downloader
#
#
#
# This script will scrape the latest image from the Himawari-8 satellite, recombining the tiled image,
# converting it to a JPG which is saved in My Pictures\Himawari\ and then set as the desktop background.
#
# http://himawari8.nict.go.jp/himawari8-image.htm
#
@maxivak
maxivak / readme.md
Last active August 5, 2019 08:47
Install TinyMCE editor 4 with Elfinder file manager in Rails 4 app

TinyMCE with file manager

This post shows how to use TinyMCE 4.1 WYSIWYG text editor in a Rails 4 application for editing content in a textarea field.

TinyMCE is a powerful online WYSIWYG editor with many plugins.

If you want to insert an image by selecting it from images stored on server or upload an image to server, then you need to have a file manager with tinyMCE. TinyMCE comes with a file manager which is not free.

elFinder is an open-source file manager which can be easily integrated with tinyMCE 4.1.

@pyk
pyk / active-record-migration-expert.md
Last active August 2, 2021 09:20
become active record migration expert (Rails 4.0.2)

become active record migration expert (Rails 4.0.2)

workflow:

create model

$ rails g model NameOfModel
    invoke  active_record
    create    db/migrate/YYYYMMDDHHMMSS_create_name_of_models.rb
@alanhamlett
alanhamlett / ajax_setup.js
Last active January 13, 2021 02:18
Sets the X-CSRFToken header for every jQuery ajax non-GET request to make CSRF protection easy. This fixes the example from Django docs here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
@harmesy
harmesy / chat.rb
Created April 2, 2012 16:30
Simple EventMachine chat server
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
class Server
attr_accessor :connections
def initialize
@connections = []
@pubis
pubis / redis.rb
Created December 11, 2011 09:07
Redis config and initialization for rails
#config/initializers/redis.rb
require 'redis'
require 'redis/objects'
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys
dflt = REDIS_CONFIG[:default].symbolize_keys
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym]
$redis = Redis.new(cnfg)
Redis::Objects.redis = $redis