This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AxiosInstance } from "axios"; | |
import RxAxios from 'axios-observable'; | |
import { delay, map, Observable, of, Subscription } from "rxjs"; | |
export class Session { | |
constructor( | |
readonly accessToken: string, | |
readonly client: string, | |
readonly uid: string, | |
readonly expiry: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dec2bin(number) | |
number = Integer(number) | |
if(number == 0) then 0 end | |
ret_bin = "" | |
while(number != 0) | |
ret_bin = String(number % 2) + ret_bin | |
number = number / 2 | |
end | |
ret_bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This will run Perl and Python scripts respectively in Rails console using 'gem escape'. Gem Escape allows to format path to the scripts properly. | |
perl_cmd = Escape.shell_command(['perl', "#{RAILS_ROOT}/bin/test_perl_script.pl"]).to_s | |
system perl_cmd | |
python_cmd = Escape.shell_command(['python', "#{RAILS_ROOT}/bin/test_python_script.py"]).to_s | |
system python_cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def for_scope(scope, user = GuestUser.new) | |
case scope | |
when 'saved' | |
user.saved_articles.scoped | |
when 'my' | |
user.tagged_articles.scoped | |
else | |
scoped | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol User { | |
var firstName: String { get } | |
var lastName: String { get } | |
func fullName() -> String | |
} | |
class CurrentUser: User { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct User { | |
let firstName: String | |
let lastName: String | |
func fullName() -> String { | |
return "\(firstName) \(lastName)" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// this is either a third party SDK interface or your own analytics client implementation | |
// that actually sends JSON across the wire to deliver tracked analytics events | |
protocol AnalyticsClient { | |
func sendAnalyticsDataToTheBackend(_ eventJSON: [String: Any]) | |
} | |
final class ConcreteAnalyticsClient: AnalyticsClient { | |
func sendAnalyticsDataToTheBackend(_ eventJSON: [String: Any]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleWeak { | |
private WeakReference<Context> weakContext; | |
public ExammpleWeak(Context context) { | |
this.weakContext = context; | |
} | |
public Context getContext() { | |
return weakContext.get(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
/** | |
* Smart Cloud, Inc. Nov 14, 2013. | |
* @author Alex Bush | |
* | |
*/ | |
public class CollectionTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :post do | |
sequence(:post_title) {|n| "Post#{n}"} | |
post_date { Time.now - 10.days } | |
post_date_gmt { (Time.now - 10.days).gmtime } | |
post_modified { Time.now - 10.minutes } | |
post_modified_gmt { (Time.now - 10.minutes).gmtime } | |
post_status {"publish"} | |
factory :artist, :class => 'Artist' do |
NewerOlder