Skip to content

Instantly share code, notes, and snippets.

@alicial
alicial / restore-deleted-records-mysql.txt
Created September 4, 2015 18:15
Restoring accidentally deleted records on Mysql
Instructions for restoring a set of arbitrary records from a backup database, which preserves autoincrement IDs.
In the backup database, create a new table that only contains the records that should be restored.
CREATE new_mytable LIKE mytable;
INSERT INTO new_mytable SELECT * FROM mytable WHERE [condition of records that should not have been deleted];
Export the new_mytable from the backup, and import it in to the production DB
mysqldump -h <backuphost> -P <port> -u <username> -p mydatabase new_mytable > new_mytable.sql
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.2/d3.min.js" charset="utf-8"></script>
<style>
body > canvas, body > svg {
position: absolute;
top: 0;
left: 0;
@alicial
alicial / mock-service-example.js
Last active June 10, 2019 14:26
AngularJS: Setting up a mocked service to use in controller unit tests.
// Mocked Service
angular.module('mock.users', []).
factory('UserService', function($q) {
var userService = {};
userService.get = function() {
return {
id: 8888,
name: "test user"
}
@alicial
alicial / gist:6941533
Created October 11, 2013 20:31
Needed to add this CORS configuration to AWS S3 bucket in order to get font files working in Firefox. Open AWS Management Console, go to your bucket, click on Properties > Permissions > Edit CORS Configuration
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>{{YOUR SITE HERE, e.g. https://example.com}}</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedHeader>Content-*</AllowedHeader>
<AllowedHeader>Host</AllowedHeader>
<AllowedHeader>x-amz-*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
function PhoneDetailCtrl($scope, $routeParams, $http) {
//...
}
@alicial
alicial / amz-s3-bucket-policy
Created September 13, 2012 18:26
Amazon S3 Bucket Policy to prevent hot linking
{
"Version": "2008-10-17",
"Id": "0c762de8-f56b-488d-a4a4-20d1cb31df2f",
"Statement": [
{
"Sid": "Allow in my domains",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
@alicial
alicial / recent-tumblr-posts.js
Created August 5, 2012 17:03
How to Display Recent Posts in Tumblr
$(function() {
var url = '/rss';
var $list = $('#recent-posts');
$.ajax({
url: url,
type: 'GET',
dataType: 'xml',
success: function(data) {
var $items = $(data).find('item');
$items.each( function() {