Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

まっは mach3

🏠
Working from home
Block or report user

Report or block mach3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mach3
mach3 / ruby-mkpasswd.rb
Created Oct 23, 2010
[Ruby Excersize] Password Generator
View ruby-mkpasswd.rb
#!/usr/bin/ruby
class MkPasswd
def initialize
@defaultOption = {
'length' => 8,
'useNumeric' => true,
'useUpperCase' => true,
'useSymbol' => true
}
@mach3
mach3 / showfeed.rb
Created Nov 16, 2010
Note for getting remote RSS Feed with ruby
View showfeed.rb
#!/usr/bin/ruby
require "open-uri"
require "rss"
begin
rss = open( "<feed url here!>" ){ |f|
RSS::Parser.parse( f.read )
}
rss.channel.items.each{ |r|
@mach3
mach3 / domdocument.php
Created Dec 8, 2010
Create association array from xml, usin domdocument.
View domdocument.php
<?php
// for example, from RSS
$dom = DOMDocument::loadXML( $string_stored_xml );
$entries = array();
foreach( $dom->getElementsByTagname("item") as $item ){
$entry = array();
foreach( $item->childNodes as $node ){
if( $node->nodeType === 1 ){
$entry[ $node->nodeName ] = $node->nodeValue;
@mach3
mach3 / getfeed.php
Created Dec 13, 2010
Get the feed informations using xpath.
View getfeed.php
<?php
$dom = @DOMDocument::loadHTMLFile( $url );
$xpath = new DOMXpath( $dom );
$query = "//link[ @rel='alternate' and ( @type='application/x.atom+xml' or "
. "@type='application/atom+xml' or @type='application/xml' or @type='text/xml' or "
. "@type='application/rss+xml' or @type='application/rdf+xml' ) ]";
$elements = $xpath->query( $query );
@mach3
mach3 / detect-feed.php
Created Dec 14, 2010
Cheep tip to detect atom or rss.
View detect-feed.php
<?php
$dom = DOMDocument::load( $url );
// TRUE when RSS 1.0/2.0
$isRSS = $dom->getElementsByTagName("item")->length > 0;
// TRUE when Atom
$isAtom = $dom->getElementsByTagName("entry")->length > 0;
@mach3
mach3 / curl_get_contents.php
Created Dec 16, 2010
The cheapest example of curl for file_get_contents
View curl_get_contents.php
<?php
function curl_get_contents( $url ){
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_HTTPHEADER, false );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec( $ch );
curl_close( $ch );
return $result;
@mach3
mach3 / jquery.togglepassword.js
Created Jan 17, 2011
Toggle and display password.
View jquery.togglepassword.js
$.fn.extend({
togglePassword : function( config ){
option = $.extend({
"postfix" : "-text"
}, config );
sync = function(){
var i = this.type.toUpperCase() === "PASSWORD" ?
this.id + option.postfix :
this.id.replace( option.postfix, "" );
$( "#" + i ).val( $(this).val() );
@mach3
mach3 / anywhere.follow.js
Created May 7, 2011
@anywhereでフォローまわりを。
View anywhere.follow.js
twttr.anywhere( function(tw){
var id_str, followMe;
id_str = "XXXXXXXXX";
followMe = function(){
if( !tw.isConnected() ){
tw.bind( "authComplete", followMe );
tw.signIn();
return;
}
tw.currentUser.isFollowing( id_str, function( f ){
@mach3
mach3 / MultiHashResult.js
Created May 7, 2011
Twitterの複数のハッシュタグの検索結果をマージする
View MultiHashResult.js
var MultiHashResult = function( tags ){
var d, self, _onLoad, _onComplete, _reset ;
self = this;
d = {
api : "http://search.twitter.com/search.json",
callback : null,
tags : null,
loaded : 0,
results : null,
tweets : null,
@mach3
mach3 / hashchange.js
Created Sep 15, 2011
location.hashの変更イベントを受け取るためのもの。
View hashchange.js
/*!
* HashChange.js
* @version 1.0
* @author mach3
* @example
* var foo = new HashChange();
* foo.config({ onInit:myInitFunc, onChange:myChangeFunc, interval:100 });
* foo.start(); // When start to observe.
* foo.stop(); // When stop to observe.
*/
You can’t perform that action at this time.