Skip to content

Instantly share code, notes, and snippets.

Alireza Bashiri azbshiri

Block or report user

Report or block azbshiri

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
View change_subscription.rb
# frozen_string_literal: true
class ChangePackage
include Failable
attr_reader :subscription, :package, :expire_date, :package_history
private *delegate :store_campagin!, :upcoming_package_change?
:current_invoice, to: :subscription
def initialize(subscription, package)
View failable.rb
module Failable
class Result < SimpleDelegator
def initialize(success, object = nil)
@success = success
super(object)
end
def success?
@success
end
View dmenu-setxkbmap.sh
#!/usr/bin/env bash
setxkbmap -query $(echo -e 'us\nir' | dmenu)
View dmenu-setxkbmap.py
#!/usr/bin/env python3
"""A dmenu setxkbmap wrapper."""
import os
import subprocess
import re
import sys
dmenu_command = "dmenu"
setxkbmap_command = "setxkbmap"
View PKGBUILD
# Maintainer: Knut Ahlers <knut at ahlers dot me>
# Contributor: Det <nimetonmaili g-mail>
# Contributors: t3ddy, Lex Rivera aka x-demon, ruario
# Check for new Linux releases in: http://googlechromereleases.blogspot.com/search/label/Stable%20updates
# or use: $ curl -s https://dl.google.com/linux/chrome/rpm/stable/x86_64/repodata/other.xml.gz | gzip -df | awk -F\" '/pkgid/{ sub(".*-","",$4); print $4": "$10 }'
pkgname=google-chrome
pkgver=73.0.3770.80
pkgrel=1
View rename.vim
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
View command_query_1.rb
class Television < ActiveModel
def turned_off?
!turned_on
end
end
class TelevisionRemote
attr_reader :television
def initialize(television)
View data-migration-3.rb
class DropSubscriptionRewards < ActiveRecord::Migration[5.2]
def up
subscription_rewards = ActiveRecord::Base.connection.select_all("select * from subscription_rewards")
subscription_rewards.each do |subscription_reward|
MissionReward.create!(
subscription_mission_id: subscription_reward["subscription_mission_id"],
reward_id: subscription_reward["reward_id"],
starts_at: subscription_reward["created_at"],
ends_at: subscription_reward["expires_at"],
redeemed_at: subscription_reward["redeemed_at"]
View data-migration-2.rb
class DropSubscriptionRewards < ActiveRecord::Migration[5.2]
def up
subscription_rewards = ActiveRecord::Base.connection.select_all("select * from subscription_rewards")
subscription_rewards.each do |subscription_reward|
MissionReward.create!(
subscription_mission_id: subscription_reward["subscription_mission_id"],
reward_id: subscription_reward["reward_id"],
starts_at: subscription_reward["created_at"],
ends_at: subscription_reward["expires_at"],
redeemed_at: subscription_reward["redeemed_at"]
View data-migration-1.rb
class DropSubscriptionRewards < ActiveRecord::Migration[5.2]
def up
subscription_rewards = SubscriptionReward.all
subscription_rewards.each do |subscription_reward|
MissionReward.create!(
subscription_mission_id: subscription_reward.subscription_mission_id,
reward_id: subscription_reward.reward_id,
starts_at: subscription_reward.created_at,
ends_at: subscription_reward.expires_at,
redeemed_at: subscription_reward.redeemed_at
You can’t perform that action at this time.