The Admin Making your administration tasks easy

Web Name: The Admin Making your administration tasks easy

WebSite: http://adminuser.org

ID:94859

Keywords:

Making,Admin,The,

Description:

In most web apps, there are two types of pages. One are those just for visitors who are not yet our customers and other belongs to APP which provides the core functionality of the service.In most scenarios all these non service based content pages are combined into app, hence overloading the app with irrelevant code resulting in slow response time and necessity to update and deploy the app for minor text changes. Continue reading Brunch, the Static site generator DBFs are a set of database file formats similar to sqlite, except that each file will have only one table. The support for reading writing dbase file formats in ruby is pretty rudimentary.The following are the gems that can be used to read write dbase files.1. SHPThe file format it supports is xbase. It supports creation of columns of type string, integer and float only. The type codes for columns types are0 - string, 1 - integer and 2 - float respectively. Even though date is a valid xbase column type, it is not supported. Simple usage isAdd #Open the file to readdbf = SHP::DBF.open('path_to/file.dbf', 'rb+')data = [] #variable to collect read datadbf.get_record_count.times do |record_no|data[record_no] ||= []dbf.get_field_count.times do |column_no|# call appropriate function according to field typedata[record_no][column_no] = case dbf.get_field_info(column_no)[:type]when 0dbf.read_string_attribute(record_no, column_no)when 1dbf.read_integer_attribute(record_no, column_no)when 2dbf.read_double_attribute(record_no, column_no)endendendputs dataWhile reading is kind of straight forward, writing to the dbf is a complicated affair. You have to create the file first then add field specifications and then add data. require "shp"#Open the file to writedbf = SHP::DBF.create('file.dbf')#declare type of columnsfields = [{name: 'name', type: 0, width: 25, decimals: 0}, {name: 'age', type: 1, width: 19, decimals: 0}]fields.each do |field_info|dbf.add_field(field_info[:name], field_info[:type], field_info[:width], field_info[:decimals])enddata = [['john', 28], ['mike', 21], ['jack', 20]]data.each_with_index do |details, record_no| details.each_with_index do |value, index|case fields[index][:type]when 0dbf.write_string_attribute(record_no, index,value)when 1dbf.write_integer_attribute(record_no, index, value)endendend#close the file after writingdbf.close2. DBFThis gem can only be used for reading from dbf files. One cannot use it to create dbf files.To use as usual add to you Gemfile data = File.open('widgets.dbf')widgets = DBF::Table.new(data)#returns all file data into rows as an array of hashes with field names as keysrows = widgets.map{|widget| widget.attributes }3. RbaseRbase lacks documentation. But if you are used to wading through code in the wild, you will quickly get a hang of it and start writing reading dbase files using this. It definitely provides a rich interface to readingTo read from a dbase file. require "rbase"require "date"dbf = RBase::Table.open('file') #notice, without .dbf extensionrecords = []dbf.each do |record|attr_hash = {}dbf.columns.each do |column|attribute_name = column.nameattr_hash[attribute_name] = record.send(attribute_name)endrecords attr_hashend The zurb foundation has a sticky top bar. But they don t have a sticky footer / lower bar. This is an attempt to implement the sticky footer bar similar to that found in cnn.comLet the footer id be sticky-footer. When we scroll up we check for the current position of the scroll of the window and add the sticky css class to the footer. When the scroll reaches the original postion of the footer we restore the original positioning.The css required for fixed footer is //save the existing postion of the footer$footer = $('#sticky-footer');$win = $(window);var ipos = $footer.offset().top;var wpos, space;function h(e){wpos = $win.scrollTop();space = $win.height() - $footer.height()*2;if (wpos + space ipos) {$footer.addClass('fixed_footer');} else {$footer.removeClass('fixed_footer');}}// this triggers the repositioning of the bar on all relevant events$(window).ready(h).resize(h).scroll(h); There can be many instances in testing with capybara where you might need to interact with hidden fields. By default capybara s find_field selector ignores hidden fields.To get the value of the hidden field you can use page.all page.all("input['name=you_input_name']", :visible = false).first.value# you have to use first as it returns and array of element matching the query criteria NodeJS is an awesome platform to build applications in javascript which can run on the server.It allows you to read n write to files asynchronously and synchronouslyWriting Data to filesThe easiest way would be write synchronously (i.e. wait till the writing operating is finished)But the preferable way of writing to files will be asynchronous in context of web apps. var fs = require('fs');fs.writeFile("/path/to/some_text.txt", "test data!", function(err) {if(err) {console.log(err);} else {console.log("file has been saved successfully");}});In this case the program will continue to execute next instruction without waiting for the file write to complete. Once the file writing is completed, the third parameter (closure ) is executed. Above method overwrite the current file. So if you want to append the data, use Continue reading Reading from and writing to files in node.js This will generate two folders, message_mailer and notification_mailer with html text views for messages, notification and message replies respectively.Next create a modify the initializer of mailboxer to include the following config Mailboxer.setup do |config|#Enables or disables email sending for Notifications and Messagesconfig.uses_emails = true#Configures the default `from` address for the email sent for Messages and Notifications of Mailboxerconfig.default_from = "admin@yoursite.com"end #Returning the email address of the model if an email should be sent for this object (Message or Notification).#If no mail has to be sent, return nil.def mailboxer_email(object)#Check if an email should be sent for that object#if truereturn "define_email@on_your.model"#if false#return nilendTo change the title of you mail messagesopen config/locales/en.yml and you will see the following line belonging to each mail you can the below line to suit to your needs en:mailboxer:message_mailer:subject_new: "Mailboxer new message: %{subject}"subject_reply: "Mailboxer new reply: %{subject}"notification_mailer:subject: "Mailboxer new notification: %{subject}" RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data. Rails admin is like bootstrap admin interface for your web app / site. To add tinymce editor to all textareas in rails_admin first add the tinymce-rails gem to your Gemfile and run bundle install.Gemfile gem 'tinymce-rails', :git = 'git://github.com/spohlenz/tinymce-rails.git', :branch = 'tinymce-4'Now got to app/assests/javascripts/rails_admin folder and include the tinymce javascript libraries to rails_admin.js.erb file like thisNow create a javascript file called tinymce.js in app/assets/javascripts/rails_admin folder and add the following code to invoke tinymce on all textareas function tinymce_load(){tinymce.init({selector: "textarea",plugins: [ "advlist autolink lists link image charmap print preview anchor", "searchreplace visualblocks code fullscreen autoresize", "insertdatetime media table contextmenu paste"],menu : "core",toolbar: "undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link"});}$(window).load(tinymce_load());$(document).on('pjax:complete', tinymce_load );A note on pjax line. RailsAdmin uses pjax for better user experience so we have to trigger the tinymce_load function when ever pjax is called so that the new textareas are also tinymced!then include this file in rails_admin.js.erb file likeNow restart your server and you have tinymce loading on all textareas. For more customization options of tinymce please refer their website. Mailbox GemMailboxer gem adds messaging capability to your models.By far of all messaging gems we have found this one easy to implement / add to your models with good documentation.Mailboxer InstallationIn you rails application addto your Gemfile and run bundle install to install it.Now go to rails application directory and run to generate the necessary migrations and then migrate the changes to your databaseConfiguring MaiboxerIn rails you can create an intializer called mailboxer.rb in folder /config/intializer and modify the default behaviour of mailboxer. An example intializer. In our setup we are not interested in user emails. so we have just disabled it. Mailboxer automatically generates a initializer for you can go and change the default settings. Mailboxer.setup do |config|#Configures if you applications uses or no the email sending for Notifications and Messagesconfig.uses_emails = false#Configures the default from for the email sent for Messages and Notifications of Mailboxerconfig.default_from = "no-reply@mailboxer.com"#Configures the methods needed by mailboxer# These methods must be implemented in the model which will be using mailboxerconfig.email_method = :email # This method is needed only if you are going to send an email for each converstion / repliesconfig.name_method = :name # This method is needed if you want to user mailboxer#Configures if you use or not a search engine and wich one are you using#Supported enignes: [:solr,:sphinx]config.search_enabled = falseconfig.search_engine = :solrendPreparing the ModelIn your user model add acts_as_messageable and implement the method name as shown below class User ActiveRecord::Baseattr_accessible :email, :first_name, :last_nameacts_as_messageable# Returns the name of the userdef name return "#{first_name} #{last_name}"endendBasic MessagingIn mailboxer when an user send message to another user, a conversation is started. So there will be a notification is created with the content of the message and a receipt of notification is add to sent box of the sending user and a receipt of notification is added to the inbox of receiving user.To send a message to user2 from user1 user1.send_message(user2, body_of_the_message, subject_of_the_message)#sending a messageTo send message to multiple users use (just pass and array of recipients to send_message function. user1.send_message([user2, user3, user4], body_of_the_message, subject_of_the_message) #message replyuser2.reply_to_conversation(conversation, "Reply body")#Reply to all in the conversation (if the conversation involves more than two users )user2.reply_to_all(receipt, "Reply body")#To reply to the message senderuser2.reply_to_sender(receipt, "Reply body") #user1 wants to retrieve all his conversationsuser1.mailbox.conversations#user1 wants to retrieve his inboxuser1.mailbox.inbox#user1 wants to get unread messages in inboxuser1.mailbox.inbox(:unread = gt; true)#user1 wants to get all the read messages in inboxuser1.mailbox.inbox - user1.mailbox.inbox(:unread = gt; true)#user1 wants to retrieve his sent conversationsuser1.mailbox.sentbox#user1 wants to retrieve his trashed conversationsuser1.mailbox.trashTo read the contents of a conversation user get the receipts of the message for him and reads the messages. The following snippet gets the messages in a conversation in reverse chronological order. #user gets the last conversation (chronologically, the first in the inbox)conversation = user1.mailbox.inbox.first#user gets it receipts chronologically ordered.receipts = conversation.receipts_for user1#using the receipts (i.e. in the view)receipts.each do |receipt|message = receipt.messageread = receipt.is_unread?end #To get the originator of the conversationconversation.originator#To get all participants of the conversationconversation.particpants#To get the first messsage of the conversationconversation.original_message#To get no of messages in the conversationconversation.count_messages#to mark a conversation as read by the participant (example user2)user2.mark_as_read(conversation)the views are added to your app/views folders so you can edit them.Thats all for now folks. If you need more info just post in the comments i will try to answerUpdate: Follow up tutorial on how to customize mailboxer viewsReferenceshttps://github.com/ging/mailboxerhttp://www.rubydoc.info/github/ging/mailboxer/frames To access view helper methods from controller / models in rails 3 you have to use view_context method. ExampleJust a note that you should avoid calling these functions within the controllers to follow mvc pattern conventions. The easiest way to install php extension is using pecl.To install you have to runif you have php installed in another location. Lets assume php is installed in /opt/phpTo install the extension you have to do is first download the extension and then unzip it and run the phpize and make and make install. Example commands to run pecl download extenstion_name # you will see a .tgz / .zip / .tar.gz fileunzip  extension_name.zip # unzip  / untar it using tar xvfz extension_name.tar.gzcd extension_name_folderexport PHP_PREFIX="/opt/php"$PHP_PREFIX/bin/phpize./configure --with-php-config=$PHP_PREFIX/bin/php-configmakemake install

TAGS:Making Admin The 

<<< Thank you for your visit >>>

Websites to related :
Company Profile

  COVID-19 Current information. Find out more hereFSG - Your partner for custom engineered system solutions in the field of industrial measuring and aut

Engineers Gallery| Arduino Proje

  Introduction:In our projects is common to use DC motors in robotics, conveyor belts, in drones, among many other Arduino projects and we want to... Ar

TC for ATEX Temperature Sensors

  COVID-19 UPDATE: We are open for business as usual and here to assist our customers. Please call on our usual number - 01895 252222, or email info@tc.

TA Instruments

  Promotions Practical Approach Webinar Training Series Dilatometry ElectroForce Mech. Test Instruments Thermal Conductivity Rubber Testing Thermal Anal

SEI External Wiki Home - Homepag

  Welcome to the SEI external Wiki homepage! This site is intended for sharing and collaborating on information.This is also now the new home for the S

wolfe enterprises, bj wolfe, b.j

  16 Series 16C Series 1/16, 1/8, 1/4 Bed Bug / Termite Infrared Thermocouples 50ft standard Custom Size Available (25ft, 75ft, 100ft) PDF Model 300

Evidence Technology Magazine - H

  On September 27, 2020, Evidence Technology Magazine co-founder Gary Gulick my business partner, mentor, friend my dad passed away at his home in Kearn

Amateur, Homebuilt, LSA Experim

  LIBRARYFLIGHT PLANNINGE6B TOOLSWEATHERHOMEBUILT AIRCRAFTSPONSOR US!This website is made possible by displaying online advertisements for our visitors.

Force Science Institute | Resear

  Welcome to Force Science Institute Dedicated to promoting the value of knowledge through empirical research in behavioral science and human dynamic

Lethbridge Monumental / Headston

  We have personalized memorials for thousands of families, just like yours.Let us help you and your family with this lasting tribute, to your loved one

ads

Hot Websites