Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created February 18, 2017 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jonathantneal/e3d16455a1ed8f4cc97d7ea549bd03eb to your computer and use it in GitHub Desktop.
Save jonathantneal/e3d16455a1ed8f4cc97d7ea549bd03eb to your computer and use it in GitHub Desktop.
Mac Setup

Install Brew and Brew Cask:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask

Brew install:

  • antigen
  • gdbm
  • git
  • icu4c
  • node
  • pcre
  • zsh

Brew Cask install:

  • adobe-creative-cloud
  • aerial
  • atom
  • box-sync
  • firefox
  • github-desktop
  • gitter
  • google-chrome
  • hyper
  • hyperdock
  • hyperswitch
  • imageoptim
  • irccloud
  • java
  • macdown
  • parallels-desktop
  • slack
  • skype
  • skype-for-business
  • subler
  • sublime-text

NPM install:

  • hpm-cli
  • npm
  • npm-check-updates
  • svgo

Next, install the following Hyper plugins:

hypercwd
hyper-blink
hyperterm-mactabs
hyperterm-tab-icons
hyperterm-atom-dark

Install the following antigen plugins to ~/.zshrc.

antigen use oh-my-zsh

antigen bundle brew
antigen bundle common-aliases
antigen bundle git
antigen bundle git-extras
antigen bundle npm
antigen bundle osx
antigen bundle paulirish/git-open
antigen bundle zsh-users/zsh-syntax-highlighting

antigen theme robbyrussell

antigen apply

And these aliases are nice:

alias edit="/usr/local/bin/atom"

alias gs="git status"
@Jayfeather12
Copy link

input->is_ajax_request()) { //show_404(); } } public function get_filter_fields() { $this->load->model('Product_options_model'); $post = $this->input->post(); $filter_fields = $this->Product_options_model->filter_fields($post['category_id']); if(empty($filter_fields)) { echo ''; die(); } if(!empty($post['code'])) { $this->load->model('Search_model'); $term = $this->Search_model->get_term($post['code']); $params = (array) json_decode($term); if(!empty($params['product_values'])) { $field_inputs = (array) $params['product_values']; } } $c = 0; $return = ''; foreach($filter_fields as $field) { $checkall = ''; if(!empty($field_inputs[$field['slug']])) { $set_values = count($field_inputs[$field['slug']]); $checkall = ($set_values == count($field['options']) ? 'checked' : ''); //open the field if it has selected field if($set_values > 0) { $c = 0; } } $return .='
'.$field['name'].'
  • All
  • '; foreach($field['options'] as $key => $option) { $unique_id = str_shuffle(substr('mikealdrinbarbadillo',0,8)); $checked =((!empty($field_inputs[$field['slug']]) && array_search($option,$field_inputs[$field['slug']]) !== FALSE) ? 'checked' :''); $return .='
  • '.$option.'
  • '; } $return .= '
'; $c++; } if (ob_get_length()) ob_end_clean(); echo $return; } public function feed_facebook() { // 4/20/2015 //may bago akong nakita, di ko pa natry //https://gist.github.com/jonathantneal/5146557 //get the id here https://graph.facebook.com/cherrymobile //$ch = curl_init("https://www.facebook.com/feeds/page.php?format=json&id=147245968622316"); error_reporting(0); $this->load->helper('text'); $limit = 1; $caching = 600; //https://smashballoon.com/custom-facebook-feed/access-token/ $feed_id = 'cherrymobile'; $access_token = "1741674466114427|d9YIWbHVvjsdwmMRp9HEQDWfedo"; $path = APPPATH.'cache/feeds'; if ( ! file_exists($path)) { //create directory mkdir($path, 0777, true); } $filename = $path.'/facebook.json'; $filetime = file_exists($filename) ? filemtime($filename) : time() - $caching - 1; if (time() - $caching > $filetime) { // try { // $response = @file_get_contents("https://graph.facebook.com/".$feed_id."/posts?limit=".$limit."&access_token=".$access_token); // $_response = json_decode($response); // } catch (Exception $e) { // $_response = null; // } // $response = file_get_contents("https://graph.facebook.com/".$feed_id."/posts?limit=".$limit."&access_token=".$access_token); // $_response = json_decode($response); //pag may error kuhain mo yung dating nacache haha if(!$_response || empty($_response->data[0])) { $response = file_get_contents($filename); } else { //di ko sure kung kelangan nga buharin haha if(file_exists($filename)) unlink($filename); file_put_contents($filename, $response); } } else { $response = file_get_contents($filename); } $response = json_decode($response); //if empty result if(empty($response->data[0])) { die(); } $result = $response->data[0]; $text = strip_tags($result->message); $post_id = explode('_', $response->data[0]->id); $url = "https://www.facebook.com/".$feed_id."/posts/".$post_id[1]; $image_link = "https://graph.facebook.com/".$post_id[1]."/picture"; if( ! empty(file_get_contents($image_link))) { $echo = '

'.$feed_id.'

'.date('M j, Y', strtotime($result->created_time)).'
'.word_limiter($text, 30).'
Read More >

'; } else { $echo = '

'.$feed_id.'

'.date('M j, Y', strtotime($result->created_time)).'
'.word_limiter($text, 30).'
Read More >

'; } $echo .= '
<script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3"; fjs.parentNode.insertBefore(js, fjs); }(document, "script", "facebook-jssdk"));</script>'; echo $echo; } public function feed_twitter() { error_reporting(0); $this->load->helper('text'); $consumerKey = 'n0rpS4054sWnoqngzSq74kIra'; $consumerSecret = 'txsjUmeaLTNu2pQrkZxCUaSrYtSaQBPgwZuzOj6jz9PfN0kRBc'; $accessToken = '123616859-99pKcvsKpaBOr3LZyMwndcN7NSk12PGqhQnEN42f'; $accessTokenSecret = 'nyNmLsVKYAUppVd22S9IIfZpOZt6Mq37HgOH9D2TbHAzF'; $username = 'cherrymobileph'; $maximum = 1; $caching = 600; $path = APPPATH.'cache/feeds'; if ( ! file_exists($path)) { //create directory mkdir($path, 0777, true); } $filename = $path.'/twitter.json'; $filetime = file_exists($filename) ? filemtime($filename) : time() - $caching - 1; if (time() - $caching > $filetime) { $filetime = time() - $caching ; $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; $base = 'GET&'.rawurlencode($url).'&'.rawurlencode("count={$maximum}&oauth_consumer_key={$consumerKey}&oauth_nonce={$filetime}&oauth_signature_method=HMAC-SHA1&oauth_timestamp={$filetime}&oauth_token={$accessToken}&oauth_version=1.0&screen_name={$username}"); $key = rawurlencode($consumerSecret).'&'.rawurlencode($accessTokenSecret); $signature = rawurlencode(base64_encode(hash_hmac('sha1', $base, $key, true))); $oauth_header = "oauth_consumer_key=\"{$consumerKey}\", oauth_nonce=\"{$filetime}\", oauth_signature=\"{$signature}\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"{$filetime}\", oauth_token=\"{$accessToken}\", oauth_version=\"1.0\", "; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Authorization: Oauth {$oauth_header}", 'Expect:')); curl_setopt($curl_request, CURLOPT_HEADER, false); curl_setopt($curl_request, CURLOPT_URL, $url."?screen_name={$username}&count={$maximum}"); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl_request); curl_close($curl_request); $_result = json_decode($response); //pag may error kuhain mo yung dating nacache haha if(isset($_result->errors)) { $response = file_get_contents($filename); } else { //di ko sure kung kelangan nga buharin haha if(file_exists($filename)) unlink($filename); file_put_contents($filename, $response); } } else { $response = file_get_contents($filename); } $result = json_decode($response); if(isset($result->errors)) { die(""); } $result = $result[0]; $echo = '

'.$result->user->name.'

'.date('M j, Y', strtotime($result->created_at)).'
'.word_limiter($result->text,30).'
Read More >

Tweet <script type="text/javascript"> window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,"script","twitter-wjs")); </script> '; echo $echo; } function subscribe() { $this->load->model('Newsletters_model'); $result = $this->Newsletters_model->subscribe($_POST['subscribe_email']); echo json_encode(array('msg' => $result)); } function test() { $this->load->library('facebook'); $this->facebook->is_authenticated(); } }

@Jayfeather12
Copy link

i am having an error to may ajax.php can you find the error in my facebook.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment