Skip to content

Instantly share code, notes, and snippets.

View prdpspkt's full-sized avatar

Pradeep Sapkota prdpspkt

  • Transport Management Office, Kawasoti
  • Nawalpur, Nepal
View GitHub Profile
@prdpspkt
prdpspkt / manifest.xml
Created October 29, 2018 04:36
Full Screen Activity with AppCompactActivity for Splash Screen
<activity
android:name=".activities.FullViewActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
/>
@prdpspkt
prdpspkt / MainActivity.java
Created October 29, 2018 04:39
Dynamically adding items and setting icons in Navigation Drawer Menu
final Menu menu = navigationView.getMenu();
for (int i = 0; i < types.size(); i++) {
MenuItem item = menu.add(R.id.notice_types, types.get(i).type_id, 0, types.get(i).name);
item.setIcon(R.drawable.asterisk);
}
@prdpspkt
prdpspkt / MainActivity.java
Created October 29, 2018 04:45
Loading another fragment in Navigation Drawer Activity Dynamically.
Fragment fragment = null;
Class fragmentClass = null;
fragmentClass = NoticeFragment.class;
try {
fragment = (Fragment) fragmentClass.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
FragmentManager fragmentManager = getSupportFragmentManager();
@prdpspkt
prdpspkt / MonthlySavingInterestCalculator.rb
Last active November 16, 2018 02:49
Calculate how much you save after some years for monthly saving...
@year = 40 #total years you want to save monthly
@months = @year*12
@saving = 200 #amount of money you want to save monthly
@yearly_interest_rate = 6 #yearly interest rate for monthly saving
@interest_calculation_duration_in_month = 3 #interest is calculated each 3 months
@monthly_interest_rate = (@yearly_interest_rate/100.0)/12.0
@amount = 0
(1..@year).each do |y|
(1..12).each do |m|
@amount = @amount + @saving
@prdpspkt
prdpspkt / removeNamedRanges.vb
Created April 18, 2019 03:54
Remove Named Range in Excel using VBA
Private Sub Workbook_Open()
Dim i As Long
Application.Calculation = xlCalculationManual
For i = ThisWorkbook.Names.Count To 1 Step -1
ThisWorkbook.Names(i).Delete
Next
Application.Calculation = xlCalculationAutomatic
End Sub
@prdpspkt
prdpspkt / file_system.cmd
Created May 19, 2019 10:33
Convert your drive's file system (FAT32 to NTFS and NTFS to FAT32) without formatting
# change directory to your drive, here in my case drive letter is D: and I want to change my file system from fat32 to ntfs
D:
# now run disk check
CHKDSK /F
# when disk check is complete run this code to change your file system without formatting
convert D:/fs:ntfs
@prdpspkt
prdpspkt / Model.rb
Created April 29, 2020 02:03
Abort action and throw error from Rails Model.
errors[:base] << "यो जिन्सी सामानसंग सम्बन्धित कारोबार अन्य दाखिला, खरिद आदेश, मागफरामहरू मध्ये कुनै एकमा देखिएकोले हटाउन सकिएन |"
throw(:abort)
@prdpspkt
prdpspkt / db.task
Created April 29, 2020 02:06
Rake Task: Adding custom rake task example
namespace :db do
desc 'Truncate all tables, except schema_migrations (customizable)'
task :truncate, [ :tables ] => 'db:load_config' do |t, args|
args.with_defaults(tables: 'schema_migrations')
skipped = args[:tables].split(' ')
config = ActiveRecord::Base.configurations[::Rails.env]
ActiveRecord::Base.establish_connection