Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am danno040 on github.
  • I am mikefeineman (https://keybase.io/mikefeineman) on keybase.
  • I have a public key whose fingerprint is 7908 034B EFC2 ED22 01FE FB77 FA73 FDCC 29FB 525C

To claim this, I am signing this object:

@Danno040
Danno040 / PackageListing.jsx
Last active November 2, 2015 21:51
Component that breaks bill, with corresponding test
import React from 'react';
import { FilteredPackageStore } from '../stores/FilteredPackageStore';
import { FilteredPackageService } from '../services/FilteredPackageService';
export default class PackageListing extends React.Component {
constructor(props) {
super(props);
this.state = this.getPackagesState();
this._onChange = this._onChange.bind(this);
}
<style>
body.mobile .posts .post_info .post_vote {
display: inline-block;
}
@media only screen and (max-width: 767px) {
body.mobile .posts .post_vote .vote_up,
body.mobile .posts .post_vote .vote_down {
display: inline-block;
}
@Danno040
Danno040 / sso_example.php
Created April 15, 2015 22:11
SSO Example code
<html>
<body>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
<label>API Key</label><br />
<input type="text" name="api_key" value="<?php echo isset($_POST['api_key']) ? $_POST['api_key'] : '' ?>" /><br />
<br />
<label>Domain</label><br />
<input type="text" name="domain" value="<?php echo isset($_POST['domain']) ? $_POST['domain'] : '' ?>" /><br />
@Danno040
Danno040 / RealdomainValidator.php
Created April 7, 2015 20:10
Extends Laravel's validator to check if a value is a "real" domain pointing to specific servers
Validator::extend('realdomain', function ($attribute, $value, $parameters) {
$domain = idn_to_ascii($value);
// Basic "is domain" check
if (filter_var('http://' . $domain, FILTER_VALIDATE_URL) === false) {
return false;
}
// Grab the A records and CNAMES
$records = dns_get_record($domain, DNS_ALL);
@Danno040
Danno040 / autoselect-category.html
Created March 16, 2015 15:52
Place this in your "categories" template in SocialEngine Cloud and the category you're viewing will be auto-populated in the composer modal
<script>
$('body').on('composer.rendered', '.composer-link', function() {
// Set default category to current category
var currentCategoryId = $('ul.dropdown-menu li.active').data('id');
$('.modal-body').find('select[name$="category"]').val(currentCategoryId).trigger('change');
});
</script>
@Danno040
Danno040 / Custom-Dropdown.html
Last active August 29, 2015 14:16
For adding a custom dropdown to the main menu in SocialEngine Cloud
<script>
$(document).ready(function() {
var html = '<li class="dropdown">';
html += '<a href="/entertainment" class="dropdown-toggle" data-toggle="dropdown">Entertainment <b class="caret"></b></a>';
html += '<ul class="dropdown-menu">';
html += '<li><a href="/entertainment/games">Games</a></li>';
html += '<li><a href="/entertainment/music">Music</a></li>';
html += '</ul>';
html += '</li>';
$('#menu ul').append(html);