Posts

Showing posts from 2010

While Loop in Azure SQL -

in azure stream analytics query want write while loop using declare/set counting. declare @x int set @x = 0 while @x < 90 begin set @x = @x + 1 *my code '@x' counter* end the error message claims: declare @x int unsupported statement. is there basic overlooked? if comment out declare command, asa sql doesn't set command. if leave out while loop , replace @x number in code, works fine.

ios - Is there any way to access an SFSafariViewController's contentOffset? -

i want have access contentoffset values of sfsafariviewcontroller. i tried subclassing sfsafariviewcontroller in order set scrollview's delegate, looks sfsafariviewcontroller doesn't expose it's scrollview. is there way set scrollview's delegate or access contentoffset values ?

python - Get intersection range of two non-discrete intervals -

given interval defined start , end point (both floats), determine intersection range second interval. example: int1 = [2. , 5.] int2 = [2.2, 7.] >>> desired_function(int1, int2) 2.8 it should handle intersection possibilities (no intersection, partial intersection, complete intersection, negative ranges etc.). attempt looks this: def intersection(int1, int2): #case 1: partial intersection on left or right border if (int2[0]<=int1[0] , int2[1]<=int1[1]) or (int2[0]>=int1[0] , int2[1]>=int1[1]): return min(int1[1],int2[1]) - max(int1[0],int2[0]) #case 2: complete overlap of 1 interval other elif (int2[0]>=int1[0] , int2[1]<=int1[1]) or (int2[0]<=int1[0] , int2[1]>=int1[1]): return min (int2[1]-int2[0] , int1[1]-int1[0]) #case 3: no overlap @ else: return 0 question: have missed , there build-in solution or package similar since want keep code simple , fast possible? you making thing...

java - Cannot parse data from the phpmyadmin -

Image
i'm trying retrieve data phpmyadmin on android app ,but first want test through logcat see if works .when test ,i don't names of users in database sadly . this showusers class : package ie.example.artur.adminapp; import android.content.intent; import android.os.bundle; import android.os.strictmode; import android.view.menu; import android.view.menuitem; import android.widget.arrayadapter; import android.widget.listview; import android.widget.toolbar; import android.os.asynctask; import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.support.v7.app.appcompatactivity; import android.view.view; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.defaulthttpclient; import java.io.bufferedreader; import java.io.inputstream; import java.io...

c# - Using constructor injection when caller expects a specific constructor signature -

i'm new di in .net c# & autofac , having problems understand how use di when can't control caller side. there 2 scenarios have problems understand. scenario 1: caller expects default constructor (without parameters) how handle scenario when still want inject service interfaces when class constructed? thinking of constructor chaining, mean have know concrete type , works around idea of di. (at least think). public class serviceworker { iservice _service; public serviceworker(iservice service) { _service = service } } public class caller { // no way change this. var serviceworker = new serviceworker(); } scneario 2: caller expects specific constructor signature (e.g. same question here. how can inject additional dependencies when caller expects exact match constructor signature? i think main issue in understanding concept is, don't see how di partially when not constructed di (caller) public class serviceworker { ...

java - How to solve Class not found in gnu.gcj.runtime.SystemClassLoader in Unix -

i trying run java class .jar file in unix environment, getting following error, exception in thread "main" java.lang.noclassdeffounderror: systembootstrap @ gnu.java.lang.mainthread.run(libgcj.so.7rh) caused by: java.lang.classnotfoundexception: systembootstrap not found in gnu.gcj.runtime.systemclassloader{urls=[], parent=gnu.gcj.runtime.extensionclassloader{urls=[], parent=null}} @ java.net.urlclassloader.findclass(libgcj.so.7rh) @ java.lang.classloader.loadclass(libgcj.so.7rh) @ java.lang.classloader.loadclass(libgcj.so.7rh) @ gnu.java.lang.mainthread.run(libgcj.so.7rh) the command using run class java -cp batchframework.jar systembootstrap dnqltrbatch dev1 systembootstrap class called , not able solve this.and new unix.

Connec to Hive from Apache Spark -

i have simple program i'm running on standalone cloudera vm. have created managed table in hive , want read in apache spark, initial connection hive not being established. please advise. i'm running program in intellij, have copied hive-site.xml /etc/hive/conf /etc/spark/conf, spark-job not connecting hive metastore public static void main(string[] args) throws analysisexception { string master = "local[*]"; sparksession sparksession = sparksession .builder().appname(connecttohive.class.getname()) .config("spark.sql.warehouse.dir", "hdfs://quickstart.cloudera:8020/user/hive/warehouse") .enablehivesupport() .master(master).getorcreate(); sparkcontext context = sparksession.sparkcontext(); context.setloglevel("error"); sqlcontext sqlctx = sparksession.sqlcontext(); hivecontext hivecontext = new hivecontext(s...

javascript - Kendo Ui nested JSON Parse -

i having issues in pushing sharepoint nested json objects "results" data can used in kendo grid. any appreciated. parse: function (data) { console.log(data.d.results.length); var results = []; (var = 0; < data.d.results.length; i++) { var items = data.d.results[i]; (var x = 0; x < item.attachmentfiles.results.length; x++) { var attachment = { attachments: item.attachmentfiles.results[x].filename }; results.push(attachment); } return data.d.results && results; } } so work around able place attachmentfiles in function column template. title: "attachmentfiles", template: function (d) { var attachments = []; (var x = 0; x < d.attachmentfiles.results.length; x++) { console.log(d.attachmentfiles.results[x].filename); attachments.push(d.attachm...

python - output dictionary data as a table in console -

i output dict data in form of table in console: dtc={ "test_case1_short":{"test_step11":"pass","test_step12":"pass","test_step_13":{"status":"failed","details":"ca marche po"}, "test_case2_longest_name":{"test_step21":"ne","test_step22":"ne"}, "test_case3_medium_name":{"test_step31":"ne","test_step32":"ne"} } note: french speakers 'dtc' shortcut dict_test_collection (!) to build table determine size of key names in order dimension column headers. can key names max length doing this: max = 0 in list(dtc.keys()): if max < len(i): max = len(i) print(max) but find not straighforward ... there way information dict.keys() or dict feature ? besides, i'd set separators "+-----------------------------+" section headers , "| ...

javascript - How to constrain proportions to something unique on HTML5 video -

Image
i have page going display video (on desktop browsers only). have code check if video landscape or portrait. then, want (here issue) if video portrait orientation, display such (with video playing balloons are. if video orientation landscape , want fill black minus margin) video here html <div id="vidmodal" class="video-wrapper" ng-show="vm.showvideo"> <img src="public/img/cancel-music.svg" alt="" id="closex"> <video src="{{vm.event.videourl}}" id="vid" loop autoplay muted poster="{{vm.event.imageurl}}"></video> </div> the js: function clickplay() { vm.hasvideo = false; //hide text-and-play-button div vm.showvideo = true; //show video default hidden (false) //make form translucent // document.getelementsbyclassname('.rsvpbox').background = "rgba(255,255,255,0.6)"; // chec...

botframework - Specifying LUIS dialog spellCheck, slot programmatically -

so far able avoid hardcoding luis appid , key doing following: var luisservice = new luisservice(new luismodelattribute(configurationmanager.appsettings["luisappid"], configurationmanager.appsettings["luisappkey"])); context.call(new luisdialog(luisservice), resumeafterdialog); and having luis dialog declared as: [serializable] public class luisdialog : luisdialog<object> { public luisdialog(iluisservice ls) : base(ls) { } .... } } but able set spellcheck=true, log, verbose , other parameters available in luismodel attribute programmatically, there way of doing that? thanks i figured out, need set luismodelattribute properties in code before creating luisservice: var luissettings = new luismodelattribute(configurationmanager.appsettings["luisappid"], configurationmanager.appsettings["luisappkey"]); luissettings.log = true; luissettings.spellcheck = true; luissettings.log = true; var luisservice = n...

Correctly splitting a string into an array : Python regex split() vs findall() -

i seem seeing differences in assumed same thing. attempting separate string array of regex matches. when try split believed should have, incorrectly array of empty strings following >>> re.split(a, tosplit) ['', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ''] however, when run findall correctly of matches such >>> matches in re.findall(a, tosplit): ... print(matches) 0b945c19de6c4857f51ec80057f5d0b79e25d56f48605b6ebf0665d455f2cb48 334892954139-cloudwatchlogsapigateway-global-us-east-1 [08/jul/2016:11:54:09 +0000] 54.237.227.51 ... etc. what functional difference between findall , split, , should doing use regex split string array.

How to go to the highest parent using jquery.mmenu -

i have created menu using jquery.mmenu. have submenu's within menu's , functionality works expected. jquery.mmenu can go closest parent. want add new link allow user go upper parent in 1 go. so lets have menu this: food --> drinks --> soft drinks --> coca cola if user @ coca cola level, want link brings user food. how solve this? i got answer jquery.mmenu developer directly (frdh) var $menu = $("#my-menu").mmenu(); var api = $menu.data( "mmenu" ); $("#some-elem").on("click", function() { api.closeallpanels(); }); he admitted somehow not in api docs yet. add later on.

excel - If Function using ISTEXT -

i making little formula test if cell has text, instead of outputting true , false, output "p" or "a". for reason, when use formula: =if(istext(search("sessiona", d2)), "p", "a") it outputs "a" every row , not sure incorrect formula. any great, thank you! =if(count(search("sessiona", d4)), "p", "a") i realized needed change count. sorry!

excel vba - Migrating Powerpoint information to Access database using VBA -

i interning large firm stores lot of source data in form of powerpoints. these powerppoints serve when communicating across departments , between suppliers but, may guess, lack robust analysis. because of this, have decided database these powerpoints access. there no direct way of doing this, know of. due strict policies, limited vba coding platform. have spent last week coding macro solve problem. again, since there no direct conversion of powerpoint access, have had solve problem rather inefficiently there few caveats. list steps , caveats below. the powerpoint information want database formatted table instead of text. have been unable find macro converts ppt tables directly excel or csv files. because of this, convert ppt files (roughly 3000) pdfs. from these generated pdf's can use adobe convert them excel or csv files. using multiple online resources , bit of own experience, have coded vba script automatically format folder of csv files format access store correctly...

javafx - Hide Cells in a tableview using CSS when columns are integers -

i have tableview 1 of columns is: private tablecolumn<userdata, integer> countlistcolumn; i have been able empty cells vanish using css in columns except one, shows 0 in each cell. i've tried following: .table-row-cell:empty { -fx-background-color: transparent; } .table-row-cell:empty { -fx-border-width: 0px; } .table-row-cell:null { -fx-background-color: transparent; } .table-row-cell:null { -fx-border-width: 0px; } .list-cell:empty { -fx-background-color: white; } .list-cell:empty { visibility:hidden; } none of these seem work, nor binding. there way hide these cells or make them respond css? below i've tried. public class guicontroller implements subscriptionobserverif { @fxml private observablelist<list> list = fxcollections.observablearraylist(); @fxml private tableview<data> table; @fxml private tablecolumn<data, integer> column; @fxml private tablecolumn<data, string...

Get Objective-C interface in Swift? -

Image
is there way view objective-c interface available in swift? for example, if declare objective-c interface: #import <uikit/uikit.h> #define string_constant @"a_string_constant" #define bool_constant yes @interface viewcontroller : uiviewcontroller @end i can access string_constant in swift not bool_constant. "navigate -> jump generated interface"

PostgreSQL Query to get the output from same table with same table values -

i have 1 table id employee leave_days leave_type type 1 abc 10 sick remove 2 abc 20 sick add 3 abc 15 annual remove 4 abc 50 annual add 5 xyz 10 sick remove 6 xyz 20 sick add 7 xyz 15 annual remove 8 xyz 50 annual add from above table group column name called leave_type , merge rows , output should follows. i have group column name leave_type , add new column called leave_allocated . in leave_allocated column, column type value add come. id employee leave_days leave_type leave_allocated 1 abc 10 sick 20 2 abc 15 annual 50 3 xyz 10 sick 20 4 xyz 15 annual 50 i tried sub query not match inner query outer query . this should help select id, employe...

mysql - Left Join with Null Script Efficiency Explanation Needed -

why use left join in sql in from clause , attach where clause entity "is null"? told efficient script , should learn methodology behind it. for example: from left join arow , brow b , crow c , drow d brow.b null; this kind of construct used when want know "a list of customers have never ordered anything" : select customer.* customers left join orders on orders.customerid = customers.id orders.id null or quote old manager of mine: "can database give me list of isn't in database?" me> "sure, can give me list of things database should tell doesn't have?" him> "how supposed know that?"

log4j2 - duplicating logs in Console & RollingFile -

hey wondering if possible have same output in console in file output. here xml config. <?xml version="1.0" encoding="utf-8"?> <configuration status="warn" name="log4j2 logs"> <properties> <property name="basepath">./logs</property> </properties> <appenders> <rollingfile name="file" filename="${basepath}/activatemaintenancepage.logs" filepattern="${basepath}/activatemaintenancepage-%d{yyyy-mm-dd}"> <patternlayout header="logging start%n%n" footer="%n%nlogging end" pattern="%3sn %30d{default} [%m] %-7level %c{30} - %m%n" /> <policies> <onstartuptriggeringpolicy minsize="0"/> <timebasedtriggeringpolicy /> <sizebasedtriggeringpolicy size="500 mb"/> ...

c# - Cassandra NumberFormatException: Zero length BigInteger -

Image
i have accountbalancedraft table contains 10 columns along column amount of type decimal . when manually inserted data it, able retrieve using select query. after when made patch update through c# amount column, received following error unable execute cql script on 'connection1': com.datastax.devcenter.cql.ui.jobs.executecqlscriptjobchangeadapter-java.lang.numberformatexception: 0 length biginteger cassandra error screenshot: the error occurs when try select amount column.but when try select other columns, there no errors. resolved issue dropping , recreating table, cannot go option further. ok. as can see here positiveinteger attributes in webservice mapped text in outsystems. i'd when calling webservice not passing values these attributes when value expected in other side. if need send null instead of "" or "0" check topic , see send default value property input parameters of consumed soap web services.

r - Two way frequency table in Rmarkdown -

Image
in way can construct two-way frequency table in rmarkdown? like: i tried use both kable function knitr package , datable function dt package, none gave me desired result. update: reproducible code example. a <- sample(x = c(1,2,3), size = 1000, replace = t) b <- sample(x = c('a', 'b', 'c'), size = 1000, replace = t) df <- data.frame(vertical_title = a, horitzontal_title = b) table(df) horitzontal_title vertical_title b c 1 118 98 106 2 106 95 121 3 128 114 114 i want 'vertical_title' , 'horizontal_title' visible table in rmarkdown. you can construct table follows: --- title: example 1 output: pdf_document --- ### test ```{r,results='asis',echo=false} library(xtable) <- sample(x = c(1,2,3), size = 1000, replace = t) b <- sample(x = c('a', 'b', 'c'), size = 1000, replace = t) df <- data.frame(vertical_title ...

javascript - Extjs 6.2.0 modern filefield as button -

i trying create filefield button icon. seems in documentation not supported in modern 6.2.0. there way? link docs: http://docs.sencha.com/extjs/6.2.0/modern/ext.field.file.html there doesn't seem way change text in default button or text accompanying it. that design. file input's text browser defined , not meant changed developer. people work around generating display:hidden file input , generic button triggers file input via js. i fear you'll have divert similar measures in extjs. for reference here's discussion on how change label of plain-old html file input element: labeling file upload button

How to add nesting to an items in array Javascript -

so if want remove nesting array items can it: var nestedarrs = [[1],[2],[3],[4],[5]]; var denestedarr = [].concat.apply([], nestedarrs); console.log(denestedarr) //prints [1, 2, 3, 4, 5]; but if need go backwards , add nesting? var unnestedarr = [7, 8, 9, 10]; var nestedarr = [] ? // want add nesting every other item in arr console.log(nestedarr); //so wanted print [[7], 8, [9], 10] //& nested arr needs based upon starting unnestedarr. var unnestedarr = [7, 8, 9, 10]; var nestedarr = unnestedarr.map(function(item, index) { return index % 2 === 0 ? [ item ] : item; }); console.log(nestedarr);

c# - How to set connection string database TDE with certificate provide -

i have local database certificate protect security of database. try using normal connection string connect, failed due database had set on security. how connect database c# if in application provide certificate , password well? our connection string now. global.connstring = string.format(@"server=(localdb)\v11.0;attachdbfilename={0}\testtde\{1};integrated security=sspi;multipleactiveresultsets=true;packet size=4096", environment.getfolderpath(environment.specialfolder.mydocuments), "tdetesting.mdf"); you can set username="username use connect database" password="its password" inside connection string. try removing integrated security

linux - How are apt-get Repositories Hosted/Managed/Architected? -

whether i'm setting new vps somewhere or installing ubuntu iso on old computer have sitting around, when want favorite programming enviornment setup need type sudo apt-get install foo baz bar and computer -- does something -- , @ end have software i'm after. how work? apt-get downloading precompiled binaries? or downloading source , building things me? or sort of other packaged thing installing? or three? regardless of which, who's building these binaries, managing these build recipes, or putting these packages? whatever apt-get doing -- bits sending me served from? i'm vaguely aware composer/vps have list of apt-get repositories checks packages. these feeds hosted on http server somewhere point @ things? or else? hosts these feeds? when i'm using package manager composer (for php), know there's master list of packages @ packagist.org composer repository, user can specify other packages repositories, , repositories point version control ...

MySQL JSON extract a single value by id -

i have database json array in column extra_fields . need extract 1 value id. the jsons looks this, though number of objects random each row: [ {"id":"1","value":"48768"}, {"id":"2","value" ["string","http:someurl"]}, {"id":"5","value":"somevalue"}, {"id":"6","value":""}, {"id":"8","value":"op-ed"}, {"id":"9","value":"8111,13498,15408"}, {"id":"10","value":"30"}, {"id":"11","value":"this target string"} ] i can extract array of ids with: select extra_fields->>"$[*].id" esqt7_k2_items; i can extract array of values with: select extra_fields->>"$[*].value" esqt7_k2_items; i can extract single value @ nth zero-orde...

vba - Use file picker to find specific documents then copy and paste -

after find file paths want able copy data 6 7 of workbooks selected , paste them active file. getting me started here great. dim wb workbook dim mypath string dim myfile string dim myextension string dim fldrpicker filedialog 'optimize macro speed application.screenupdating = false application.enableevents = false application.calculation = xlcalculationmanual 'retrieve target folder path user set fldrpicker = application.filedialog(msofiledialogfolderpicker) fldrpicker .title = "select target folder" .allowmultiselect = false if .show <> -1 goto nextcode mypath = .selecteditems(1) & "\" end 'in case of cancel nextcode: mypath = mypath if mypath = "" goto resetsettings 'target file extension (must include wildcard "*") myextension = "*.xls*" 'target path ending extention myfile = dir(mypath & myextension) 'loop through each excel file ...

php - pagination doesn't work with custom page on wordpress -

i have problem wordpress. problem pagination in custom page doesn't work searched bunch of answers on google couldn't find right answer problem. works in index.php never works on custom pages. if click number 2 of pagination never go page 2 , staying in page 1 , nothing changed before clicked next page number. here codes problem. hope can fix reading! , page i'm making. http://hongikezer.esy.es/hongik_draw/draw/ first code functions.php second 1 css file third code single-hingik_draw.php custom page <?php function register_my_menu() { register_nav_menu('header-menu',__('header menu')); } add_action('init','register_my_menu'); /*sidebar enable*/ function register_my_sidebar() { register_sidebar( array(('name')=>__('main sidebar') ) ); } add_action('init','register_my_sidebar'); add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 232, 211); //custom...

json - Deserializing links collection to a dictionary -

i'm trying deserialize output rest api call. fragment of json here: "_links": { "invoices": { "href": "url", "type": "application/json" }, "members": { "href": "otherurl", "type": "application/json" }, "paymentcard": { "href": "yetanotherurl", "type": "application/json" }, "self": { "href": "evenmoreurl", "type": "application/json" }, "session": { "href": "andyesevenmoreurl", "type": "application/json" }, "subscription": { "href": "tiredofurls", "type...

air - Adobe Media Server Alternative for VideoChat -

i have video chat app working on web(flash) , android via adobe air, uses adobe media server (rtmp) backend video streaming , shared objects, question is, if there server or solution provides many many live video broadcast maybe using h.264 codec android , ios, have sort of user list , room list stored in database or similar, want move away adobe has many limitations on mobile devices. live video crucial in 1 many broadcasts have hundreds of viewers @ same time. thanks reading! ulex.fr created rtmp connector asterisk (the free pbx platform). used asterisk vonference application, allows create conference rooms 1 many configuration, audio , video. 1 limitation power of server. can plan scalable architecure in order broadcast 1 video many (many unlimited). developp specific protocol connect , manage connection based on telephony events. think done direct rtmp connection skip protocol too. all project done ulex.fr free, opensource , gpl. get full project here : https://...

vim: replace sub-match with the same number of new strings -

my plan pretty standard search replace, replacing instances of old_string new_string . problem want arbitrary number of old_strings following specific prefix . example: old_string = "a" new_string = "b" prefix = "xxxx" xxxxaaaaaaaa => xxxxbbbbbbbb xxxxaaapostfix => xxxxbbbpostfix xxaaaa => xxaaaa etc. i'm not sure how this. imagine there's way s/xxxxa*/xxxxb{number of a's}/g or something, have no idea is. you can this! use \= register evaluate vimscript. :h s/\= : substitute expression *sub-replace-expression* *sub-replace-\=* *s/\=* when substitute string starts "\=" remainder interpreted expression. special meaning characters mentioned @ |sub-replace-special| not apply except "<cr>". <nl> character used line break, can 1 double-quote string: "\n". prepend backslash real <nl> character (which nul in file). then can use rep...

c# - DateTime.TryParseExact not parsing -

i have datetime string , trying parse datetime object, not working. 2 datetime objects never have values set. i'm sure it's simple i'm not seeing. see wrong code? string issued = "tue 25 jul 2017 16:47:38"; string expires = "tue 25 jul 2017 18:47:38"; string format = "ddd dd mmm yyyy hh:mm:ss"; datetime dissued; datetime dexpires; datetime.tryparseexact(issued, format, cultureinfo.invariantculture, datetimestyles.none, out dissued); datetime.tryparseexact(expires, format, cultureinfo.invariantculture, datetimestyles.none, out dexpires); i ran code , seemed work fine. i'm assuming you're hard coding strings exemplary sake. consider putting break statement @ point in code 2 values filled , inspecting them see content. excess whitespace or chars throw error. try .trim(); on string too. removes white space @ beginning , end of string transform string so: " cat " -> "cat"

Python (large) lists and unique combinations: smartest way to do them -

i read page on here: get unique combinations of elements python list the solution approved works... ... but works " small " lists (100 elements, example). i have "big" list of strings ( 1 million of elements ) , infamous "memoryerror" exception. what best way unique combos on large lists? thanks in advance per inspectorg4dget's comment , linked answer , if large number of values in initial list duplicated, filter them out through set first, find combos. from itertools import combinations elements = [gigantic list] uniques = tuple(set(elements)) combos = [','.join(str(thing) thing in combo) combo in combinations(uniques, 2)]

Cannot find "/libs/wcm/foundation/components/page/stats.js" in AEM 6.3 -

we calling "/libs/wcm/foundation/components/page/stats.js" using sightly data.sly.use 1 of our component's html in aem 6.1. however, stats.js file doesn't exist in aem6.3. after deploying code getting below error while accessing page- 25.07.2017 12:24:50.000 *info* [commitstats] commitstats 37 commits user clientlibs-service location http-get:/editor.html/content/mysite/en/test.html [commitstats overhead 0ms = 0.0us / commit] 25.07.2017 12:24:52.278 *error* [10.44.48.230 [1500999891705] /content/mysite/en/test.html http/1.1] com.day.cq.wcm.core.impl.wcmdevelopermodefilter error during include of slingrequestpathinfo: path='/content/mysite/en/test/jcr:content', selectorstring='null', extension='html', suffix='null' org.apache.sling.scripting.sightly.sightlyexception: required script resource not located: /libs/wcm/foundation/components/page/stats.js. caller /apps/mysite/components/page/base/head.html @ org.apache.sling.scriptin...

python - How to use normal user(Models) in machina -

i have created model of instructor (for project coursera , udacity instructor uploads video student) name, uname, email, password, pic project , have done code session , stuff it. now want add forums in so, tried use django-machina came know machina forums can used superuser or staff user , have separate model instructor. what should do? (how can create staff user model?) models.py instructor: class instructor(models.model): fname = models.charfield(max_length=30) lname = models.charfield(max_length=30) uname = models.charfield(max_length=30) email = models.charfield(max_length=100) password = models.charfield(max_length=20) pic = models.filefield() def __str__(self): return self.email

r - How to efficiently swap elements between columns in a dataframe? -

i asked similar question before , realized previous example little special in sense factor levels equally-spaced. here want reframe question in more generic way, , solutions in old thread not work properly. suppose have following dataframe in r : set.seed(1) (tmp <- data.frame(x = 1:10, r1 = sample(c('a','d','f','g','i'), 10, replace = true), r2 = sample(c('d','f','g','i','z'), 10, replace = true), stringsasfactors=false)) x r1 r2 1 1 d f 2 2 d d 3 3 f 4 4 f 5 5 d 6 6 g 7 7 8 8 g z 9 9 g f 10 10 notice 2 columns r1 , r2 not share same elements. want following: if difference between elemet index (sequential order among elements) of column r1 , of column r2 odd number, levels of 2 factors need switched between them, can performed through following code: for(ii in 1:dim(tmp)[1]) { kk <- which(levels(as.factor(tmp$r2)) %in% tmp[ii,'r2']...